cap-go / capacitor-updater Goto Github PK
View Code? Open in Web Editor NEWLive update for capacitor apps
Home Page: https://capgo.app
License: Mozilla Public License 2.0
Live update for capacitor apps
Home Page: https://capgo.app
License: Mozilla Public License 2.0
Hi there, thanks for sharing this project, I'm really looking forward to using it! Sorry if the answer to this is already out there and I've just missed it!
I'm just trying to give it a test with Android but I'm just wondering what I should be including in the update zip file?
I am using svelte, so I had assumed I should just zip up the contents of the build folder when running npm run build
I am attempting to apply the update as follows, I'm not catching any exceptions but the app doesn't appear to update.
const updateNow = async () => {
try {
const version = await CapacitorUpdater.download({
url: 'http://192.168.0.39:45456/api/v1/mockreceiver/build.zip',
})
await SplashScreen.show()
await CapacitorUpdater.set(version)
await SplashScreen.hide()
}catch (e){
console.log(e);
}
}
Thanks again
Oh also, should I be adding anything to onCreate()
in MainActivity for this plugin? I'm currently assuming not.
The goal to this is to allow X% of the user base receive the update
See if that fine for them, and continue to have more, until 100%
Thanks for the great work,
May we have documentation for the end points required for autoupdate system so if wanted, we can host auto updates from our own servers.
Thanks
if the native app is 1.2.3and the live update is 2.0.0
then the update is skip
In the future it can be cool to let user have a way to continue updating app in past version
like for 1.x.x
have way to push in channel fix and feature in backport way
I’m thinking to have 3 tiers pricing + freemium
Solo | Maker | Team | |
---|---|---|---|
App | 1 | 3 | 10 |
Channels per app | 2 | 10 | 50 |
Versions history per app | 10 | 100 | 1000 |
monthly update per app | 2,500 | 25,000 | 250,000 |
Sharing per app | No | 10 | 100 |
Price | $14 by month | $39 by month | $99 by month |
CapacitorUpdater.addListener('download', (info: any) => {
console.log('download was fired', info.percent);
});
Property 'addListener' does not exist on type 'CapacitorUpdaterPlugin'
core.js:6210 ERROR Error: Uncaught (in promise): Error: "CapacitorUpdater" plugin is not implemented on android
Error: "CapacitorUpdater" plugin is not implemented on android
My function for update is :
async updateHybrid() {
var self = this;
const version = await CapacitorUpdater.download({
url: 'http://92.168.1.25/downloadhybridversion',
})
await CapacitorUpdater.set(version)
}
my versiın is "capacitor-updater": "^1.0.22"
I'm not sure if this warning can be ignored or not, but here's the Google article on the issue:
Hello !
Since recent ionic crazy pricing trying to find solution :)
I am new to capacitor only cordova used in the past .
testing on iOS
async update() { const update = await CapacitorUpdater.updateApp({ url: 'https://myftpurl/upate.zip', }); console.log(update); }
gives me {done: false}
(upate.zip is my www zipped)
I love this project. I've got it setup and updating properly, but I can't clean up old versions.
const {versions} = await CapacitorUpdater.list();
const {current} = await CapacitorUpdater.current();
for (const v of versions) {
if (v !== current) {
CapacitorUpdater.delete({version: v})
.then(() => console.log('deleted version', v));
}
}
This gives an error:
Error: Uncaught (in promise): Error: Delete failed, version don't exist
Error: Delete failed, version don't exist
at Object.cap.fromNative (:414)
Am I using the API wrong or is this a bug?
Hi,
This looks like a fantastic library, but the AGPL licence seems a little prescriptive, correct me if I'm wrong, but If I include your npm package I would need to open source the rest of my Ionic mobile application?
Thanks
Neil
Call reset() without any value for toAutoUpdate
. App will native crash with NPE.
2022-04-24 12:38:03.402 15564-15693/com.maritlabs.topdecked.mtg V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 70857513, pluginId: CapacitorUpdater, methodName: reset
2022-04-24 12:38:03.402 15564-15693/com.maritlabs.topdecked.mtg V/Capacitor: callback: 70857513, pluginId: CapacitorUpdater, methodName: reset, methodData: {}
2022-04-24 12:38:03.403 15564-15666/com.maritlabs.topdecked.mtg E/Capacitor: Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:592)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at ee.forgr.capacitor_updater.CapacitorUpdaterPlugin._reset(CapacitorUpdaterPlugin.java:180)
at ee.forgr.capacitor_updater.CapacitorUpdaterPlugin.reset(CapacitorUpdaterPlugin.java:196)
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:592)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
--------- beginning of crash
2022-04-24 12:38:03.405 15564-15666/com.maritlabs.topdecked.mtg E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
Process: com.maritlabs.topdecked.mtg, PID: 15564
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:601)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:592)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at ee.forgr.capacitor_updater.CapacitorUpdaterPlugin._reset(CapacitorUpdaterPlugin.java:180)
at ee.forgr.capacitor_updater.CapacitorUpdaterPlugin.reset(CapacitorUpdaterPlugin.java:196)
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:592)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
2022-04-24 12:38:03.409 550-564/system_process W/ActivityTaskManager: Force finishing activity com.maritlabs.topdecked.mtg/.MainActivity
2022-04-24 12:38:03.459 550-4034/system_process I/ActivityManager: Process com.maritlabs.topdecked.mtg (pid 15564) has died: fg TOP
If the new version of the updated code does not run properly, the system should revert to the previously working version.
Previous plugins that have implemented "code-push updates" provide a feature where developers can specify when an update succeeds. Otherwise the update will be rolled back to the previous working version:
onAppStarted() {
CapacitorUpdater.notifyApplicationReady();
// If ".notifyApplicationReady()" is not called within ~5s (or a configured timeout) of an update & reload,
// the update should be considered failed and the previous version should be loaded.
}
Example/Reference: https://github.com/mapiacompany/capacitor-codepush#codepushnotifyapplicationready
When zip download fails for some reason, the plugin just outputs the error "Download failed" Without any clear message / error on what went wrong or why download has failed. Not helpful for debugging / investigating the issue
Bug confirmed zip downloads with http is failing and working perfectly with https
Allow user to click in the app somewhere to try the beta channel of the app.
this will send to server the device id who will be necessary for future feature like AB testing
Hi,
since version 1.3.0 usage stats are sent to cappgo. The documentation says that I can change this behaviour to send usage stats to a custom server. But I don't want to send any usage stats. Is there a possibility to disable sending usage stats at all? From some tests I think configuring an empty string as statsUrl does the job, but I'm not sure whether this is the correct way/intended behaviour because the docs don't say anythin about this.
auto-update not need app id to be set since it’s same as app
Channel could be set by default as “production” and override with config
Then URL should be set by default since that the main usage.
To allow user to enable auto-update a new config should appear.
This will result in simple first time config. just upload app and make it public
something like if native version > JS version reset to native
for that, we need library for version compare android :
https://github.com/G00fY2/version-compare
and iOS:
Hi,
I'm experimenting with your lib, cause I also want to use a simple workflow without AppFlow.
I'm testing with an Android emulator and the latest version of capacitor-updater and having issues with the list() method.
Calling list() from my Angular application and calling JSON.stringify on the result shows that the serialization seems not to work as expected.
CapacitorUpdater.list().then(x => console.log(JSON.stringify(x)));
// output: {"versions":"[/data/user/0/de.tcwolfach/files/versions/SmuZ3lRen7, /data/user/0/de.tcwolfach/files/versions/gy1sGvaZ5f, /data/user/0/de.tcwolfach/files/versions/ey6GwoMTy8, /data/user/0/de.tcwolfach/files/versions/nlppoSqiMB]"}
As you can see the versions-Property is not a an array of strings. Instead it's a string property.
I'm not a Java expert, but it looks like the resulting string is not a correctly serialized string, it's the result of calling toString() on an ArrayList.
Changing this code in node_modules folder:
public void list(PluginCall call) {
ArrayList<String> res = implementation.list();
JSObject ret = new JSObject();
ret.put("versions", res);
call.resolve(ret);
}
to this code
public void list(PluginCall call) {
ArrayList<String> res = implementation.list();
JSObject ret = new JSObject();
ret.put("versions", new JSArray(res));
call.resolve(ret);
}
fixed the problem.
I only checked the issue for Android, maybe the same problem occurs in iOS.
currently, only the last set have a name not others
Love the effort here, will be watching closely.
One thing I'd like to point out if it's not been considered already is the install method. It would be great to be able to configure how the app is updated;
a) Immediate install/switch/restart when the download of the new update is finished
b) Manual through function so developer can choose the best time when they know the user isn't doing something important.
c) Install/restart/switch when the app re-gains focus (e.g with App.addListener('appStateChange'
)
If you wait until re-focus then it prevents the user being in the middle of something when you randomly restart the app. (doesn't handle the case of them switching apps temporarily to copy/paste or reference something else during a form filling exercise of course).
Apple won't allow you to show an install update prompt so you have to consider the different background approaches.
Will you be exposing events for download started/finished/failed/update available etc?
Allow 50% to have one version and 50% to have other to see if that improve specific stat
Hi, thank u for awesome project
I know Just package has asyncProgressHandler for HTTP requests. Maybe that can provide progress event for us.
I thought there might be people like me who want to show the current progress as a percentage to users.
Best regards
On Android currently the request sent to the server to check for auto updates is including header cap_version_build which has the value of versionName value from android project. Since versionName is free text it might be useful to introduce a new header containing versionCode value from android project since versionCode is unique while versionName can free text.
Hi!
How will this work? if I set the update url is mywebsite.com/dist.zip, will download the zip every time app goes to background? how will it know if the zip has updates?
Hello when I tried to run cap sync I get this error. It only happens when this package installed. Is there anyone that have any idea?
✖ Updating iOS native dependencies with pod install - failed!
✖ update ios - failed!
[error] Ignoring ffi-1.15.0 because its extensions are not built. Try: gem pristine ffi --version 1.15.0
Analyzing dependencies
objc[25636]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib
(0x1efa1f130) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
(0x1065202c8). One of the two will be used. Which one is undefined.
objc[25636]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1efa1f180) and
/Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x106520318).
One of the two will be used. Which one is undefined.
When performing manual updates, there is currently no protection against a failed/bad update.
Methods that return version information should also return an update status (success/error/pending):
notifyAppReady()
was called for this versionnotifyAppReady()
was never calledset()
and never launched.export interface VersionInfo {
version: string; // version identifier (random numbers returned by native plugin)
status: 'success' | 'error' | 'pending'; // current status of this version
}
A configurable notifyAppReadyTimeout should be added to capacitor.config.ts (this is optional, but if not provided, the documentation should let the developer know how quickly this needs to be called):
// capacitor.config.ts
...
"appId": "**.***.**",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"notifyAppReadyTimeout": 10000 // <-- Milliseconds
}
}
...
** If notifyAppReady()
is not called within the specified (or default value of) notifyAppReadyTimeout
, the app should revert to the previous success
version, or builtin
if none was previously set: **
We perform the first download/set, as the current version is builtin
, which can never be rolled back:
const builtin: VersionInfo = await CapacitorUpdater.current();
console.log(builtin);
// { version: 'builtin', status: 'success' }
const downloaded: VersionInfo = await CapacitorUpdater.download({ url: 'https://.../dist.zip' });
console.log(downloaded);
// { version: 'fdc2b4ae1', status: 'pending' }
const set: VersionInfo = await CapacitorUpdater.set('fdc2b4ae1');
console.log(set);
// { version: 'fdc2b4ae1', status: 'pending' } <--- status is still pending because app needs to reload
Now the app app is reloaded, and we call notifyAppReady()
which returns the updated version info:
const current: VersionInfo = await CapacitorUpdater.notifyAppReady();
console.log(current);
// { version: 'fdc2b4ae1', status: 'success' }
The native code also stores a previous()
version:
const previous: VersionInfo = await CapacitorUpdater.previous();
console.log(previous);
// { version: 'builtin', status: 'success' } <-- this should always return 'builtin' / 'success' if no previous version is set.
Now, for example's sake, we perform another manual update:
const info: VersionInfo = await CapacitorUpdater.download({ url: 'https://.../dist.zip' });
console.log(info);
// { version: 'b9a7dc3e5', status: 'pending' }
const info: VersionInfo = await CapacitorUpdater.set('b9a7dc3e5');
console.log(info);
// { version: 'b9a7dc3e5', status: 'pending' } <--- status is still pending because app needs to reload
Now the app app is reloaded, but notifyAppReady()
is NOT called. The native plugin waits for notifyAppReadyTimeout
milliseconds, then rolls back to previous version and reloads the application from native code.
The app starts successfully on the previous()
version fdc2b4ae1
and notifyAppReady()
is called again, but is a no-op for this version since it has already been confirmed successful:
const current: VersionInfo = await CapacitorUpdater.notifyAppReady();
console.log(current);
// { version: 'fdc2b4ae1', status: 'success' }
Listing all available version would return something like the following:
const downloads: VersionInfo[] = await CapacitorUpdater.list();
console.log(downloads);
// [
// { version: 'builtin', status: 'success' }
// { version: 'b9a7dc3e5', status: 'failed' }
// { version: 'fdc2b4ae1', status: 'success' }
// ]
Final note about fallback behavior:
On the rare occurrence that the previous version fdc2b4ae1
ALSO fails to call notifyAppReady()
within the specified notifyAppReadyTimeout
, the app could be reverted to builtin
, but this behavior is probably something that could probably be configurable in capacitor.config.ts
:
const current: VersionInfo = await CapacitorUpdater.notifyAppReady();
console.log(current);
// { version: 'builtin', status: 'success' }
"plugins": {
"CapacitorUpdater": {
"allowRollbackToBuiltin": true
}
}
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.