microsoft / cordova-plugin-code-push Goto Github PK
View Code? Open in Web Editor NEWCordova plugin for CodePush
Home Page: http://appcenter.ms
License: Other
Cordova plugin for CodePush
Home Page: http://appcenter.ms
License: Other
Start a new project in visual studio with the Ionic Tabs App template. Double-click the config.xml file, plugins tab, select Git and add the path for CodePush https://github.com/Microsoft/cordova-plugin-code-push. Add the plug-in. Try to run or build the project produces the following errors
I'm with a problem in the update after update it installs what was downloaded but after you close and open the application sometimes it shows again that has update, or whether it is the same update .
my code:
var onPackageDownloaded = function (localPackage) { localPackage.install(onInstallSuccess, onError); }; var onUpdateCheck = function (remotePackage) { if (!remotePackage) { console.log("The application is up to date."); } else { console.log("A CodePush update is available. Package hash: " + remotePackage.packageHash); $scope.startUpdate = function(){ remotePackage.download(onPackageDownloaded, onError, onProgress); $scope.aceppted = true; } } }; window.codePush.checkForUpdate(onUpdateCheck, onError, deploymentKey);
*Thank you, I'll wait.
Steps to reproduce:
Expected:
Update succeeded.
Actual:
Navigation to the updated version does not occur at update time, only at restart time. Initial investigation shows there might be a timing issue (native side does not find the package start page). More investigation is needed.
Hi,
I'm using Cordova and codepush with the latest versions.
Here's the plugins that i additinaly used:
code-push 1.6.0-beta "CodePushAcquisition"
com.phonegap.plugins.oauthio 0.2.1 "OAuth.io"
com.verso.cordova.clipboard 0.1.0 "Clipboard"
cordova-instagram-plugin 0.5.3 "Instagram"
cordova-plugin-app-version 0.1.8 "AppVersion"
cordova-plugin-code-push 1.5.1-beta "CodePush"
cordova-plugin-crypt-file 0.0.1 "CordovaCrypt"
cordova-plugin-customurlscheme 4.1.3 "Custom URL scheme"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-file 4.1.1 "File"
cordova-plugin-file-transfer 1.5.0 "File Transfer"
cordova-plugin-globalization 1.0.2 "Globalization"
cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.3.1-dev "InAppBrowser"
cordova-plugin-splashscreen 3.1.0 "Splashscreen"
cordova-plugin-statusbar 2.1.1 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-socialsharing 5.0.10 "SocialSharing"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
org.apache.cordova.console 0.2.10 "Console"
org.apache.cordova.inappbrowser 0.4.1-dev "InAppBrowser"
org.apache.cordova.plugin.ActivityIndicator 1.0.0 "Activity Indicator"
org.apache.cordova.vibration 0.3.10-dev "Vibration"
phonegap-plugin-push 1.5.3 "PushPlugin"
When i'm using codePush.sync() command on deviceready it downloads the package and get Preinstall failure error when it's started to install
Here you can see the console log that i catched via Chrome: http://imgur.com/7i74s1z
I suspect that CordovaCrypt plugin cause this because it's encrypting all files when i use "cordova prepare" command. (It's decrypting that files when application is running)
Any suggestions that you can give me?
We are thinking about adding an aditional parameter to apply(), such that the user can optionally be alerted when their application is rolled back to the previous version in case of a bad update. We are also thinking about adding a new flag (potentially to LocalPackage) such that developers can react to the rollback.
there are description and packageSize that are undefined. i think it'd be great if you can tell the user before hand what he can expect size-wise.
// current remotePackage dump
appVersion: "0.4.32"
deploymentKey: "8960f81c-xxx"
description: undefined
downloadUrl: "https://codepush.blob.core.windows.net/storagev2/xxx"
failedInstall: false
isMandatory: false
label: "v3"
packageHash: "fbc201670xxx"
packageSize: undefined
As per, https://github.com/Microsoft/code-push/tree/master/cli,
the appStoreVersion parameter indicates the minimum version of the app to which this push is applicable.
I see that from the code, the plugin makes a http request as follows:
https://codepush.azurewebsites.net/updateCheck?deploymentKey=key&appVersion=appversion&packageHash=&isCompanion=false
Ideally it should not update if the appVersion on the hot code push package is greater then the current version being passed in the url. But it seems to still get the update
For example in our case the hot code push package had appVersion set to 0.45.2 and the url being invoked is
https://codepush.azurewebsites.net/updateCheck?deploymentKey=masked-key&appVersion=0.45.0&packageHash=&isCompanion=false
It still get the package and prompts user to update.
I followed the steps described on the project site, and I'm getting this error, what this means?
As soon as I'm about to install the OTA update, I'm asked to allow file storage permissions on the device. This is rather ugly and can turn users away from updating.
Probably not entirely a code-push, but maybe others stumble upon the same issue.
Can this storage permission be omitted with Marshmallow somehow? declaring in the AndroidManifest or something?
First of all, thank you so much for adding WKWebView support which bumps iOS modern specs. This is a ticket for achieving the same thing for the Android platform. I am trying to get this working with Crosswalk Project and the specifically the cordova webview plugin.
In case of iOS after adding code push plugin all the cordova plugins are working on minimizing the app. Working fine on android.
Walking through the Getting Started documentation on my iOS device, I was not successful out of the box for the following reasons:
<access origin="https://codepush.azurewebsites.net/" />
didn't work on iOS, I needed to remove the trailing /
<access origin="https://codepush.blob.core.windows.net" />
requirements:
cordova platform add [email protected]
i get the following build error:
No visible @interface for 'UIView' declares the selector 'loadRequest:'
- (void)loadURL:(NSURL*)url {
[((CDVViewController *)self.viewController).webView loadRequest:[NSURLRequest requestWithURL:url]];
}
The CodePush plugin doesn't work within the context of an app that was deployed via Ionic livereload (e.g. ionic emulate android -l
), due to the fact that Ionic's livereload functionality actually "converts" your app into a "hosted app" (i.e. the app is requesting the content from your dev machine as opposed to running it locally on the device), at which point, the WebView enforces CORS. The app itself will still work, but because the CodePush server doesn't enable CORS (by returning the proper headers), the call to either checkForUpdate
or sync
will fail, because the server isn't explicitly granting access to the client.
In the non-livereload case, the <access>
elements in config.xml
and the browser's CSP tag determine which domains the app can access, but unfortunately, in the livereload case, these are ignored, and CORS is enforced. This appears to be a known issue and we should investigate whether there is a workaround that doesn't require us to modify the server purely for debugging purposes.
Additionally, we should update our README and/or the error message we display in the CLI to make this limitation much more clear than it currently is. If we can't figure out a workaround, maybe our plugin could detect that it's running in hosted mode (by examining the current URL on the native side?), and effectively "disable" itself so that API calls no-op as opposed to fail.
This is somewhat related to #28, since devs would use livereload as a design-time/debugging tool, and ideally, CodePush wouldn't flat out fail in this case, as opposed to something more graceful/intuitive.
1, User need to know what's updated
2, Provide the API to show user the package download progress dialog(user should be able to cancel download it if not a mandatory update)
Normally cordova prepare
would be enough however, for example, Ionic 2 requires a compilation step to compile (using gulp) TypeScript and SCSS to create the www directory.
When using the code-push release-cordova
command it runs cordova prepare
for you, however with Ionic 2 no new changes would be compiled into the platform's www directory.
Maybe think about running a complete cordova build
step in order to ensure all scripts and everything is ready for the appropriate platform for the release-cordova command?
This is a tracking issue for adding a link to the CLI repo in the application update package description.
I'm surprised you are not offering support for your own operating system.
Shouldn't be hard to use WinRT as the technology stack?
Why isn't the plugin not depending on a common Cordova file transfer plugin?
I am pulling out my hair trying to find a Cordova solution that will allow for hot code updates, as well as take advantage of the vastly more performant WKWebview. I have tried the following plugins without much luck. I realize since each of these plugins alter the way the application code is loaded, compatibility may not be so trivial. Has there been any experimental setups? Any insight or at least nudges in the right direction would be much appreciated!
https://github.com/Telerik-Verified-Plugins/WKWebView
https://github.com/apache/cordova-plugin-wkwebview-engine
https://github.com/apache/cordova-plugins/tree/master/wkwebview-engine-localhost
Not sure if this helps, but here is a related issue with a similar plugin to code push nordnet/cordova-hot-code-push#42
The logs that are outputted by sync
when an update is installed only takes into account the installMode
property, and not the new mandatoryInstallMode
property. For example, if you install an mandatory update using InstallMode.ON_NEXT_RESUME
, but the installMode
property was set to InstallMode.ON_NEXT_RESTART
, the plugin would incorrectly log "Update is installed and will be run on the next app restart." after installing the mandatory update. The install logic makes it clear why this behavior exists.
This isn't a hugely critical bug, but these logs are pretty important for users to diagnose their update experience, so making it accurate is important. I actually got a bit confused by this when dogfooding the new mandatoryInstallMode
property :)
I did a hot code push without mandatory flag. When I run,
code-push deployment ls
It shows Mandatory: No
But the updateCheck api always returns "isMandatory": true
Can you check on this.
If I create and install a new version of my application with Ionic for android including cordova-plugin-code-push 1.5.1-beta "CodePush",
*BEFORE * I release any updates via code-push, I get the following error when client invokes window.codePush.sync():
Checking for update.
[CodePush] An update is available. {"failedInstall":false}
Downloading package.
[CodePush] Downloading update package
[CodePush] The remote package does not contain a download URL.
[CodePush] An error occurred during sync.
An error occured while checking for updates
It should return SyncStatus.UP_TO_DATE. When I release an update, it updates, and then it works normal, even if there are no new updates.
On iOS I receive the following popups after an update is installed.
I thought this may be related to my CSP:
<meta http-equiv="Content-Security-Policy" content="default-src *; img-src 'self' * data: gap:; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
let syncOptions = {
installMode: InstallMode.IMMEDIATE,
updateDialog: false
};
window.codePush.sync(this.syncStatusCallback.bind(this), syncOptions, this.syncStaticDownloadProgress.bind(this));
How can I prevent these popups from displaying?
code-push 1.8.0-beta "CodePushAcquisition"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-preferences 0.7.7 "AppPreferences"
cordova-plugin-app-version 0.1.8 "AppVersion"
cordova-plugin-badge 0.7.2 "Badges"
cordova-plugin-code-push 1.5.1-beta "CodePush"
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-contacts 2.0.1 "Contacts"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-directions 0.4.3 "Directions"
cordova-plugin-file 4.1.1 "File"
cordova-plugin-file-transfer 1.5.0 "File Transfer"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-inappbrowser 1.2.1 "InAppBrowser"
cordova-plugin-queries-schemes 0.1.1 "App Queries Strings"
cordova-plugin-splashscreen 3.2.0 "Splashscreen"
cordova-plugin-statusbar 2.1.2 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-socialsharing 5.0.11 "SocialSharing"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
ionic-plugin-keyboard 2.0.1 "Keyboard"
phonegap-plugin-push 1.6.0 "PushPlugin"
Is there a way to only release partial updates from the www
folder?
e.g. there was only a small hotfix change in app.routes.js
, i don't want to upload the whole www
folder.
Hello I'm trying the sample application and testing it with VS Android simulator. First, can we use simulator for testing the codepush ?
My app identifies that there is an update when I click update button then its error out. I can see that file is getting downloaded by debugging the Index.JS
function (downloadProgress) {
console.log("Downloading " + downloadProgress.receivedBytes + " of " + downloadProgress.totalBytes + " bytes.");
});
Error is captured here
case SyncStatus.ERROR:
app.displayMessage("An error occured while checking for updates");
break;
Thanks for your help !
Regards,
Sowmyan
When running
cordova plugin add cordova-plugin-code-push
No dependencies (code-push, cordova-plugin-file-transfer, etc.) are installed if there are no platforms added to the cordova project.
ionic plugin add cordova-plugin-code-push
Fetching plugin "cordova-plugin-code-push" via npm
Running command: "C:\Program Files\nodejs\node.exe" c:\Users\dylan.vdmerwe\Projects\GraduateApp\hooks\after_plugin_add\010_register_plugin.js c:\Users\dylan.vdmerwe\Projects\GraduateApp
Saving plugin to package.json file
The plugins are installed when a platform is added. But I believe the deps should be installed regardless of any platform being added.
Remove plugin process should work the same way.
Repro Steps:
Result:
Web view does not re-open in the current page, but navigates back to the start page due to https://github.com/Microsoft/cordova-plugin-code-push/blob/master/src/android/CodePush.java#L324
This behaviour is unique to CodePush-ed apps. A normal cordova app will re-open in the current page before being sent to the background. Also, the behavior only appears for apps that have already been updated once or more via CodePush, it does not occur If the app is a fresh install (from Play Store).
I am testing code-push for new ionic app. I followed the guide and everything is setup correctly.
I have tried this 4-5 times at least and every time, it's the same issue. It uploads zip file and once upload is done, Internal Server error is shown. In case, it makes any difference, I am trying to upload it from India.
Now, problem is when mobile app tries to update to new version, it gives error. If, it is single file, it gives error - Cannot unzip file.
If, it is templates folder - It gives error. - Start page of application not found.
Can we have some more details returned, instead of just Internal Server error.
afaik this is how it's done in the react ms code push, too.
anything that speaks against it?
When I try to upload a build to Android, the update downloads successfully and running codePush.restartApplication()
loads from the new code. However, when I force kill the app and open it again, I get a console error that says Uncaught TypeError: Cannot read property 'reportStatus' of undefined
before any of my app code runs. I'm assuming this is the reportStatus
function on the codePush
object. My hunch is that the reportStatus function is getting called before the Cordova deviceready
event when the codePush object becomes available.
When I downgrade to [email protected]
, I don't get the error.
I'm using the Crosswalk plugin at version 1.6.0.
ionic plugin add cordova-plugin-code-push
will install 1.5.0-beta. had to use ionic plugin add [email protected]
to get the latest version.
npm bump?
I have left my config.xml file with blank strings for the CodePushDeploymentKey. In code I then determine what the appropriate deploymentKey is and then use the syncOptions method to set the key.
When I run the app, the correct key is set. I get the "Checking for update" status. Then in the logs I see:
ERROR: [CodePush] Could not get the CodePush configuration. Please check your config.xml file.
ERROR: [CodePush] An error occurred during sync.
I thought the whole point of setting the value in the syncOptions was to manually be able to set the key?
<platform name="android">
<preference name="CodePushDeploymentKey" value="" />
<platform name="ios">
<preference name="CodePushDeploymentKey" value="" />
getCodePushKey(): string {
if (this.device.isAndroid) {
if (AppConstants.IsDebugMode)
return ''; // staging
else
return ''; // production
}
else if (this.device.isIos) {
if (AppConstants.IsDebugMode)
return ''; // staging
else
return ''; // production
}
return undefined;
}
let syncOptions = {
installMode: InstallMode.IMMEDIATE,
updateDialog: false,
deploymentKey: this.getCodePushKey(),
};
window.codePush.sync(this.syncStatusCallback.bind(this), syncOptions, this.syncStaticDownloadProgress.bind(this));
I'm not an Android user so I can't say whether this behavior is idiomatic or not across apps. But, it's a little odd that the update prompt isn't actually modal, and can be dismissed by touching anywhere outside of the prompt, as opposed to requiring the end-user to actually touch the accept or ignore buttons. I could kind of see this behavior making sense in the optional-update scenario, where dismissing the dialog is effectively an alternative way of ignoring the update, but in the case of a mandatory update, it seems like the prompt should be modal since you have no choice but to continue. Would an end-user ever expect to dismiss a non-modal dialog, only to have it actually force the behavior as if they accepted the prompt?
We had received feedback about this behavior on the React Native plugin, and ended up making the dialog modal/non-dismissable, so the end-user needed to click a button when an update prompt is displayed. Personally, I like this behavior, and its consistent with how we behave on iOS.
is switching deployment keys possible or would it mess with the diffing and such?
given there would be ios-production and ios-development.
Once an update has been installed, the next time the app runs and tries to check for an update, it gets stuck on the CHECKING_FOR_UPDATE status and does not move.
It seems as though the checkForUpdate callback does not fire once an update has been installed?
let syncOptions = {
installMode: InstallMode.IMMEDIATE,
updateDialog: false
};
window.codePush.sync(this.syncStatusCallback.bind(this), syncOptions, this.syncStaticDownloadProgress.bind(this));
I'm working on Android. I've tried with and without Crosswalk.
Your system information:
Cordova CLI: 6.1.0 (cordova-lib@undefined)
Ionic Version: 2.0.0-beta.3
Ionic CLI Version: 2.0.0-beta.22
Ionic App Lib Version: 2.0.0-beta.12
OS:
Node Version: v5.7.0code-push 1.8.0-beta "CodePushAcquisition"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-preferences 0.7.7 "AppPreferences"
cordova-plugin-app-version 0.1.8 "AppVersion"
cordova-plugin-badge 0.7.2 "Badges"
cordova-plugin-code-push 1.5.1-beta "CodePush"
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-contacts 2.0.1 "Contacts"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-directions 0.4.3 "Directions"
cordova-plugin-file 4.1.1 "File"
cordova-plugin-file-transfer 1.5.0 "File Transfer"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-inappbrowser 1.2.1 "InAppBrowser"
cordova-plugin-queries-schemes 0.1.1 "App Queries Strings"
cordova-plugin-splashscreen 3.2.0 "Splashscreen"
cordova-plugin-statusbar 2.1.2 "StatusBar"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova-plugin-x-socialsharing 5.0.11 "SocialSharing"
cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
ionic-plugin-keyboard 2.0.1 "Keyboard"
phonegap-plugin-push 1.6.0 "PushPlugin"
Hi I'm finding that after running:
code-push release app-android build/www/ 0.11.1 --deploymentName Staging
I get the following error:
file:///data/data/bundle.app.name.id/files/codepush/deploy/versions/8sds645e6325b1bfcac0181c396d377a21946f764526cd7cd0480c6c2a47d9a/www/cordova.js Failed to load resource: net::ERR_FILE_NOT_FOUND
cordova.js seems to be requested from the codepush path, how do I fix this? do I need to set cordova.js path to ../../../../../www/cordova.js ?
Hi,
I've encountered an issue trying to compile my TypeScript code envolving the cordova file transfer plugin.
interface FileUploadOptions {
...
/** A map of header name/header values. Use an array to specify more than one value. */
headers?: Object[];
}
Shouldn't it be:
headers?: Object;
instead? This way is working fine. I looked up the File Transfer Docs, (even if it's not updated) and doesn't mention array object in the headers param.
I guess the same is for FileDownloadOptions
Am i missing something?
Thank you,
Bye
Hi, i've implemented codepush into our app and everything seems to be working well with the exception of killing the app and restarting. Is there anything specific i need to do to ensure that the app starts from the most recently downloaded update as opposed to the app store version? what's happening now is it will load the app store version and fetch the download for the update.
Info that might be important, we're using the lastest codepush version and cordova 5.4.0.
My code for handling the update is pretty standard:
btnHandler = function(){
window.codePush.sync(
function (syncStatus) {},
{
updateDialog: true,
installMode: InstallMode.IMMEDIATE,
ignoreFailedUpdates: false
},
function (downloadProgress) {
console.log("Downloading " + downloadProgress.receivedBytes + " of " + downloadProgress.totalBytes + " bytes.");
}
);
}
If you upgrade the cordova-plugin-file
plugin to the latest release (4.2.0
), and try to sync a CodePush update on Android, the following error is logged to the console when the plugin attempts to install the update: "Could not get application subdirectory".
This error is coming from here, so something seems to have regressed in the logic that detects the directory that the CodePush update should be written to. The release notes for 4.2.0
indicate that a change was made to the resolveLocalFileSystemURL
method on Android, which is exactly the method that is failing, so this commit may provide a pointer into the issue.
As soon as I downgrade the cordoba-plugin-file
plugin back to 4.1.1
everything works again. I didn't appear to have any issues on iOS, so it seems like the problem is isolated to just Android. The release notes for 4.2.0 don't indicate any changes to resolveLocalFileSystemURL
on iOS, so that seemingly makes sense.
Can add a SyncStatus before download?
because if I click continue button for update alert.
I can do anything on this page and change another page.
but I want to show my loading function to limit user touch screem.
sorry my bad english.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.