cap-codepush
v7.0.2
Published
CodePush Plugin for Capacitor. Working with Capacitor 7.
Downloads
432
Maintainers
Readme
Capacitor Plugin for CodePush
This version is a fork of Mapiacompany's Capacitor Codepush, updated to work with the latest Capacitor. I use this daily in my company.
References
Setup a Codepush Server
Setup Codepush CLI
Take a look at the original README for this project
I simplified this documentation to provide a quick Getting Started. For any doubt or extended functionality, consult the original README:
Install the plugin to your Capacitor project
Capacitor 7
npm i cap-codepush@7Previous versions
Old naming convention
Capacitor 6
npm i cap-codepush@3Capacitor 5
npm i cap-codepush@2Capacitor 4
npm i cap-codepush@1Add App to the CodePush Server via CLI
Install the CLI
Authentication
Authenticate the CLI to your server
Don't have a Codepush Server?
code-push register https://your-codepush-server-ip:10443Use your own credentials provided by the server admin.
Register a New App
Each app must have two versions:
One for Android (suffix
-android)One for iOS (suffix
-ios)
The platform can be ios or android.
The technology to select is cordova, even if you are using Capacitor.
code-push app add <app-name-with-suffix> <platform> <technology>
# Example (execute both for each app):
code-push app add myapp-ios ios cordova
code-push app add myapp-android android cordovaProject Integration
Add the following snippet in app.component.ts:
Example with Ionic+Angular
import { CodePush, InstallMode } from 'cap-codepush';
async ngOnInit() {
await this.initializeCodepush();
}
private async initializeCodepush() {
CodePush.sync({
onSyncStatusChanged: (syncStatus) => {
console.log('Sync status changed: ', syncStatus);
},
installMode: InstallMode.IMMEDIATE,
}).then(
(status) => {
if (status) {
console.log(status);
}
},
(error) => {
if (error) {
console.log(error);
}
}
);
}Update capacitor.config.ts with:
plugins: {
CodePush: {
SERVER_URL: "https://your-codepush-server.com:10443/",
IOS_DEPLOY_KEY: IS_DEV ? "[your development key]" : "[your production key]",
ANDROID_DEPLOY_KEY: IS_DEV ? "[your development key]" : "[your production key]",
}
}Releasing a New Version of Your App
The path to the public folder is always:
Android:
android/app/src/main/assets/public/iOS:
ios/App/App/public/
Manual Release
ionic cap sync # synchronize Ionic with native project
code-push release <app-name> <public-folder-path> <target-version> -d <deployment>
# Example:
ionic cap sync
code-push release myapp-android android/app/src/main/assets/public/ 1.0.0 -d "Production"
code-push release myapp-ios ios/App/App/public/ 1.0.0 -d "Production"Useful Commands
List all apps available on the CodePush server
code-push app lsList all deployments for a given app
code-push deployment ls <app-name>
# To show deployment tokens as well:
code-push deployment ls <app-name> -k
# Example:
code-push deployment ls myapp-iosDelete All Deployments for an App
⚠️ This command will not rollback updates already installed by users.
code-push deployment clear <app-name> <deployment-name>
# Example:
code-push deployment clear myapp-android Production
code-push deployment clear myapp-android Staging