All Projects → Dellos7 → example-cordova-code-push-plugin

Dellos7 / example-cordova-code-push-plugin

Licence: other
Ionic + Cordova Code Push Plugin Example

Programming Languages

CSS
56736 projects
typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to example-cordova-code-push-plugin

ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-64.44%)
Mutual labels:  cordova, ionic, cordova-plugin
Ionic4
This repo contains example code for ionic4. Get Step by Step tutorial of this repo examples using https://ampersandacademy.com/tutorials/ionic-framework-4
Stars: ✭ 37 (-17.78%)
Mutual labels:  cordova, ionic, cordova-plugin
scanbot-sdk-example-ionic
Scanbot scanner SDK example app for Ionic with Cordova.
Stars: ✭ 24 (-46.67%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-flurryanalytics
Adds support for all that Flurry Analytics flavored goodness to your Cordova based apps
Stars: ✭ 23 (-48.89%)
Mutual labels:  cordova, ionic, cordova-plugin
ionic4-image-crop-upload
Ionic 4, Angular 7 and Cordova Crop and Upload Image
Stars: ✭ 16 (-64.44%)
Mutual labels:  cordova, ionic, ionic4
cordova-plugin-today-widget
Add a today widget app extension target to your cordova project.
Stars: ✭ 51 (+13.33%)
Mutual labels:  cordova, ionic, cordova-plugin
Cordova Admob Pro
🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.
Stars: ✭ 690 (+1433.33%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-apkupdater
This plugin allows your Android app to download and install compressed updates without the Google Play Store.
Stars: ✭ 46 (+2.22%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-android-window-background
Simple Cordova plugin to set Android window background on start-up 🎨 🍭
Stars: ✭ 15 (-66.67%)
Mutual labels:  cordova, ionic, cordova-plugin
Cordova Plugin Fingerprint Aio
👆 📱 Cordova Plugin for fingerprint sensors (and FaceID) with Android and iOS support
Stars: ✭ 236 (+424.44%)
Mutual labels:  cordova, ionic, cordova-plugin
ionic-signature-pad
Ionic plugin to input singnature pad
Stars: ✭ 15 (-66.67%)
Mutual labels:  ionic, cordova-plugin, ionic4
ionic4-boilerplate
🚀 boilerplate for ionic4 with CI based on travis and fastlane. doc and example are provided
Stars: ✭ 25 (-44.44%)
Mutual labels:  cordova, ionic, ionic4
Ionic Native
Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
Stars: ✭ 2,129 (+4631.11%)
Mutual labels:  cordova, ionic, cordova-plugin
Unityionicintegration
A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
Stars: ✭ 94 (+108.89%)
Mutual labels:  cordova, ionic, cordova-plugin
ionic4-angular7-example
Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps
Stars: ✭ 57 (+26.67%)
Mutual labels:  cordova, ionic, ionic4
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-57.78%)
Mutual labels:  cordova, ionic, cordova-plugin
cordova-plugin-zeep
Zip compression/decompression for the cordova/phonegap platform
Stars: ✭ 27 (-40%)
Mutual labels:  cordova, cordova-plugin
cordova-gmv-barcode-scanner
A Cordova barcode scanning plugin based on the Google Mobile Vision library for iOS & Android.
Stars: ✭ 48 (+6.67%)
Mutual labels:  cordova, cordova-plugin
cordova-plugin-wkkeyboardfix
Cordova plugin to provide a temporary fix for an iOS 12 and 13 bug involving keyboards in WKWebView.
Stars: ✭ 14 (-68.89%)
Mutual labels:  cordova, cordova-plugin
v-cupertino
A Vue 3 Wrapper for Cupertino Pane Library
Stars: ✭ 17 (-62.22%)
Mutual labels:  cordova, ionic

cordova-code-push + Ionic example

Example of how to set up a basic Ionic APP with the code-push cordova plugin.

Prepare the Ionic APP

ionic start codepush-ionic-test blank

cd codepush-ionic-test

ionic cordova plugin add cordova-plugin-code-push

sudo npm install --save @ionic-native/code-push

ionic cordova platform add ios

ionic cordova platform add android

Code push set up

sudo npm install

sudo npm install -g code-push-cli

code-push login

This command will open the browser and you will have to create an account with the code-push cloud services (you can use your Github, Google, Hotmail one). After successful sign-up, you must copy the token provided by the browser in the terminal.

code-push app add codepush-ionic-test-ios ios cordova

code-push app add codepush-ionic-test-android android cordova

It's better to add two different apps in your code-push account for each platform so you can handle them separately.

See again the deployment keys:

code-push deployment ls codepush-ionic-test-android -k

code-push deployment ls codepush-ionic-test-ios -k

Now set up these keys in your config.xml:

<platform name="android">
    <preference name="CodePushDeploymentKey" value="YOUR-ANDROID-DEPLOYMENT-KEY" />
</platform>
<platform name="ios">
    <preference name="CodePushDeploymentKey" value="YOUR-IOS-DEPLOYMENT-KEY" />
</platform>

Modify src/app/app.module.ts (to set CodePush as provider):

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

import { CodePush } from '@ionic-native/code-push';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    CodePush,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

Finally, use the plugin! Modify src/app.component.ts (this basic set up will show an alert to handle updates):

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';

import { CodePush, InstallMode, SyncStatus } from '@ionic-native/code-push';
import { AlertController } from 'ionic-angular/components/alert/alert-controller';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = HomePage;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
              private codePush: CodePush,  private alertCtrl: AlertController) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
      this.checkCodePush(); //Use the plugin always after platform.ready()
    });
  }

  checkCodePush() {
    
     this.codePush.sync({
      updateDialog: {
       appendReleaseDescription: true,
       descriptionPrefix: "\n\nChange log:\n"   
      },
      installMode: InstallMode.IMMEDIATE
   }).subscribe(
     (data) => {
      console.log('CODE PUSH SUCCESSFUL: ' + data);
      
     },
     (err) => {
      console.log('CODE PUSH ERROR: ' + err);
      
     }
   );
  }

}

Note: to handle more advanced code-push sync options, as creating your custom mechanism of handling updates with custom UI, etc., you should check out the cordova code-push plugin API reference and examples.

Now, you should build your app and test it in your emulator/physical device. You will be only building it once, and then releasing the updates throw code-push.

ionic cordova build ios

ionic cordova run ios

ionic cordova build android

ionic cordova run android

Release the updates

Each time you modify anything in your code, you release an update like this:

ionic cordova prepare ios

code-push release codepush-ionic-test-ios ./platforms/ios/www/ 0.0.1 --description "Your awesome change description" -d "Staging" (the -d flag can be "Production" or "Staging", so you can manage and test your releases against staging APPs)

ionic cordova prepare android

code-push release codepush-ionic-test-android ./platforms/android/app/src/main/assets/www/ 0.0.1 --description "Your awesome change description" -d "Staging" (the -d flag can be "Production" or "Staging", so you can manage and test your releases against staging APPs)

⚠️ The path changes from cordova-android 6 to 7. So in <= 6.x it's ./platforms/android/assets/www/ and and in >= 7.x it's ./platforms/android/app/src/main/assets/www/. Just check your cordova-android package version in the package.json file.

Note: the update will only be released for those devices matching the 0.0.1 version of your app.

Releasing updates pro tips

If you would like to release an update but not make it available until you specify it, you could release the update with the disabled mode enabled. Like this:

ionic cordova prepare android

code-push release codepush-ionic-test-android ./platforms/android/assets/www/ 0.0.1 --description "Your awesome change description" -x true (see the -x flag, that marks the release as disabled)

This would send the release to the code push server, but it won't be downloable by the users. Then, whenever you want to, you would mark the release as not disabled, and thus immediately downloable, with the following command:

code-push patch codepush-ionic-test-android Staging -x false

What happens if we make a mistake in the release? We could rollback the release. This would make this release unavailable for the users, and would also make available the prior release to the one you are rollbacking available again for donwload. You can make a rollback with the following command:

code-push rollback codepush-ionic-test-android Staging

Note: check out the code-push cli README for a more advanced use.

Screenshots app update

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].