This version is a fork of Mapiacompany's Capacitor Codepush, updated to work with the latest Capacitor. I use this daily in my company.
I simplified this documentation to provide a quick Getting Started. For any doubt or extended functionality, consult the original README:
npm i cap-codepush@7
Old naming convention
npm i cap-codepush@3
npm i cap-codepush@2
npm i cap-codepush@1
Don't have a Codepush Server?
code-push register https://your-codepush-server-ip:10443Use your own credentials provided by the server admin.
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 cordovaAdd the following snippet in app.component.ts:
Example with Ionic+Angular
ngOnInit() {
if (this.platform.is("capacitor")) {
await this.initializeCodepush();
}
}
private async initializeCodepush() {
codePush
.sync({
onSyncStatusChanged: (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]",
}
}The path to the public folder is always:
-
Android:
android/app/src/main/assets/public/ -
iOS:
ios/App/App/public/
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"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-ioscode-push deployment clear <app-name> <deployment-name>
# Example:
code-push deployment clear myapp-android Production
code-push deployment clear myapp-android Staging