Using Appflow's deploy feature involves installing and configuring the cordova-plugin-ionic plugin properly. If you follow the steps given in the Appflow SDK installation guide within a Capacitor application, the plugin will be properly configured. This guide provides some technical details on what the that process accomplishes in case you need to change anything, examine the existing configuration, or convert an application from Cordova to Capacitor.
Technical Details
Running "ionic deploy add" ("ionic live-update add" in Ionic v7+) updates two configuration files: android/app/src/main/res/values/strings.xml and ios/App/App/Info.plist. These files are only updated if the platforms have been added to your project. For this reason it is best to add the platforms to the project first, then add the cordova-plugin-ionic plugin afterwards.
The following contents are added to each of these files:
android/app/src/main/res/values/strings.xml
<string name="ionic_app_id">499503</string>
<string name="ionic_channel_name">master</string>
<string name="ionic_update_method">background</string>
<string name="ionic_max_versions">2</string>
<string name="ionic_min_background_duration">30</string>
<string name="ionic_update_api">https://api.ionicjs.com</string>
ios/App/App/Info.plist
<key>IonAppId</key>
<string>499503</string>
<key>IonChannelName</key>
<string>master</string>
<key>IonUpdateMethod</key>
<string>background</string>
<key>IonMaxVersions</key>
<string>2</string>
<key>IonMinBackgroundDuration</key>
<string>30</string>
<key>IonApi</key>
<string>https://api.ionicjs.com</string>
The first three values shown in each file (app id, channel name, and update method) can be added/updated via "ionic deploy configure" ("ionic live-update configure" in Ionic v7+) if needed. If the last three values are missing, they will need to be added to the appropriate files manually.
Cordova to Capacitor
With a Cordova application, the app id, channel name, and update method are all specified as variables for the plugin. The Cordova build process then updates the native projects as they are generated and prepared.
Capacitor does not have this process since you as a developer are in full control of the native projects, including the files mentioned above. So if you are converting an application from Cordova to Capacitor and already have the deploy plugin installed you will need to manually update the strings.xml and info.plist files.
The easiest process for adding the required items is to uninstall the plugin and then add it again. To do this, run the following commands from the root folder of your application.
$ npm rm cordova-plugin-ionic
$ ionic deploy add # ionic live-update add in Ionic v7+
Alternatively, if you want to be a little more "hands on", you can run "ionic deploy configure" and then manually add the parts that are missing. That process looks like this:
- Run "ionic deploy configure" in your application's root folder
- You will be asked for the app id, channel name, and update method
- The Ionic CLI will update the two files for you
- Open the files and add the max versions, min background duration, and update API values as noted above
At this point, your native applications are properly configured for Ionic Appflow's live deploy services. Be sure to commit these changes.
Comments
0 comments
Article is closed for comments.