@capgo/capacitor-updater 4.3.7 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +40 -15
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +2 -2
- package/dist/esm/web.d.ts +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +6 -1
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +14 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -510,12 +510,12 @@ Listen for download fail event in the App, let you know when download has fail f
|
|
|
510
510
|
### getDeviceId()
|
|
511
511
|
|
|
512
512
|
```typescript
|
|
513
|
-
getDeviceId() => Promise<{
|
|
513
|
+
getDeviceId() => Promise<{ deviceId: string; }>
|
|
514
514
|
```
|
|
515
515
|
|
|
516
516
|
Get unique ID used to identify device (sent to auto update server)
|
|
517
517
|
|
|
518
|
-
**Returns:** <code>Promise<{
|
|
518
|
+
**Returns:** <code>Promise<{ deviceId: string; }></code>
|
|
519
519
|
|
|
520
520
|
--------------------
|
|
521
521
|
|
|
@@ -45,7 +45,7 @@ public class CapacitorUpdater {
|
|
|
45
45
|
private static final String bundleDirectory = "versions";
|
|
46
46
|
|
|
47
47
|
public static final String TAG = "Capacitor-updater";
|
|
48
|
-
public static final String pluginVersion = "4.
|
|
48
|
+
public static final String pluginVersion = "4.4.1";
|
|
49
49
|
|
|
50
50
|
public SharedPreferences.Editor editor;
|
|
51
51
|
public SharedPreferences prefs;
|
|
@@ -357,7 +357,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
357
357
|
}
|
|
358
358
|
call.resolve(ret);
|
|
359
359
|
}
|
|
360
|
-
|
|
360
|
+
);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
);
|
|
@@ -619,11 +619,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
619
619
|
|
|
620
620
|
if (
|
|
621
621
|
latestVersionName != null &&
|
|
622
|
-
|
|
623
|
-
|
|
622
|
+
!"".equals(latestVersionName) &&
|
|
623
|
+
!current.getVersionName().equals(latestVersionName)
|
|
624
624
|
) {
|
|
625
625
|
final BundleInfo latest =
|
|
626
|
-
|
|
626
|
+
CapacitorUpdaterPlugin.this.implementation.getBundleInfoByName(latestVersionName);
|
|
627
627
|
if (latest != null) {
|
|
628
628
|
if (latest.isErrorStatus()) {
|
|
629
629
|
Log.e(
|
|
@@ -648,16 +648,24 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
648
648
|
}
|
|
649
649
|
if (latest.isDeleted()) {
|
|
650
650
|
Log.i(
|
|
651
|
-
|
|
652
|
-
|
|
651
|
+
CapacitorUpdater.TAG,
|
|
652
|
+
"Latest bundle already exists and will be deleted, download will overwrite it."
|
|
653
653
|
);
|
|
654
654
|
try {
|
|
655
|
-
final Boolean deleted =
|
|
655
|
+
final Boolean deleted =
|
|
656
|
+
CapacitorUpdaterPlugin.this.implementation.delete(latest.getId(), true);
|
|
656
657
|
if (deleted) {
|
|
657
|
-
Log.i(
|
|
658
|
+
Log.i(
|
|
659
|
+
CapacitorUpdater.TAG,
|
|
660
|
+
"Failed bundle deleted: " + latest.getVersionName()
|
|
661
|
+
);
|
|
658
662
|
}
|
|
659
663
|
} catch (final IOException e) {
|
|
660
|
-
Log.e(
|
|
664
|
+
Log.e(
|
|
665
|
+
CapacitorUpdater.TAG,
|
|
666
|
+
"Failed to delete failed bundle: " + latest.getVersionName(),
|
|
667
|
+
e
|
|
668
|
+
);
|
|
661
669
|
}
|
|
662
670
|
}
|
|
663
671
|
}
|
|
@@ -679,6 +687,22 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
679
687
|
final String url = (String) res.get("url");
|
|
680
688
|
final BundleInfo next =
|
|
681
689
|
CapacitorUpdaterPlugin.this.implementation.download(url, latestVersionName);
|
|
690
|
+
final String checksum = (String) res.get("checksum");
|
|
691
|
+
if (!checksum.equals("") && next.getChecksum() != checksum) {
|
|
692
|
+
Log.e(
|
|
693
|
+
CapacitorUpdater.TAG,
|
|
694
|
+
"Error checksum " + next.getChecksum() + " " + checksum
|
|
695
|
+
);
|
|
696
|
+
final Boolean res =
|
|
697
|
+
CapacitorUpdaterPlugin.this.implementation.delete(next.getId());
|
|
698
|
+
if (res) {
|
|
699
|
+
Log.i(
|
|
700
|
+
CapacitorUpdater.TAG,
|
|
701
|
+
"Failed bundle deleted: " + next.getVersionName()
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
682
706
|
final JSObject ret = new JSObject();
|
|
683
707
|
ret.put("bundle", next.toJSON());
|
|
684
708
|
CapacitorUpdaterPlugin.this.notifyListeners("updateAvailable", ret);
|
|
@@ -709,7 +733,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
709
733
|
CapacitorUpdaterPlugin.this.notifyListeners("noNeedUpdate", retNoNeed);
|
|
710
734
|
}
|
|
711
735
|
}
|
|
712
|
-
|
|
736
|
+
);
|
|
713
737
|
}
|
|
714
738
|
}
|
|
715
739
|
)
|
|
@@ -737,10 +761,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
737
761
|
if (backgroundValue != null) {
|
|
738
762
|
taskRunning = true;
|
|
739
763
|
final Long timeout = Long.parseLong(backgroundValue);
|
|
740
|
-
if(backgroundTask != null) {
|
|
764
|
+
if (backgroundTask != null) {
|
|
741
765
|
backgroundTask.interrupt();
|
|
742
766
|
}
|
|
743
|
-
backgroundTask =
|
|
767
|
+
backgroundTask =
|
|
768
|
+
new Thread(
|
|
744
769
|
new Runnable() {
|
|
745
770
|
@Override
|
|
746
771
|
public void run() {
|
|
@@ -754,7 +779,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
754
779
|
}
|
|
755
780
|
}
|
|
756
781
|
}
|
|
757
|
-
|
|
782
|
+
);
|
|
758
783
|
backgroundTask.start();
|
|
759
784
|
} else {
|
|
760
785
|
this._checkCancelDelay(false);
|
|
@@ -834,8 +859,8 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
834
859
|
public void run() {
|
|
835
860
|
try {
|
|
836
861
|
Log.i(
|
|
837
|
-
|
|
838
|
-
|
|
862
|
+
CapacitorUpdater.TAG,
|
|
863
|
+
"Wait for " + CapacitorUpdaterPlugin.this.appReadyTimeout + "ms, then check for notifyAppReady"
|
|
839
864
|
);
|
|
840
865
|
Thread.sleep(CapacitorUpdaterPlugin.this.appReadyTimeout);
|
|
841
866
|
CapacitorUpdaterPlugin.this.checkRevert();
|
package/dist/docs.json
CHANGED
|
@@ -614,9 +614,9 @@
|
|
|
614
614
|
},
|
|
615
615
|
{
|
|
616
616
|
"name": "getDeviceId",
|
|
617
|
-
"signature": "() => Promise<{
|
|
617
|
+
"signature": "() => Promise<{ deviceId: string; }>",
|
|
618
618
|
"parameters": [],
|
|
619
|
-
"returns": "Promise<{
|
|
619
|
+
"returns": "Promise<{ deviceId: string; }>",
|
|
620
620
|
"tags": [
|
|
621
621
|
{
|
|
622
622
|
"name": "returns",
|
|
@@ -354,11 +354,11 @@ export interface CapacitorUpdaterPlugin {
|
|
|
354
354
|
/**
|
|
355
355
|
* Get unique ID used to identify device (sent to auto update server)
|
|
356
356
|
*
|
|
357
|
-
* @returns {Promise<{
|
|
357
|
+
* @returns {Promise<{ deviceId: string }>} an Promise with id for this device
|
|
358
358
|
* @throws An error if the something went wrong
|
|
359
359
|
*/
|
|
360
360
|
getDeviceId(): Promise<{
|
|
361
|
-
|
|
361
|
+
deviceId: string;
|
|
362
362
|
}>;
|
|
363
363
|
/**
|
|
364
364
|
* Get the native Capacitor Updater plugin version (sent to auto update server)
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
|
@@ -25,7 +25,7 @@ export class CapacitorUpdaterWeb extends WebPlugin {
|
|
|
25
25
|
}
|
|
26
26
|
async getDeviceId() {
|
|
27
27
|
console.warn('Cannot get ID in web');
|
|
28
|
-
return {
|
|
28
|
+
return { deviceId: 'default' };
|
|
29
29
|
}
|
|
30
30
|
async getPluginVersion() {
|
|
31
31
|
console.warn('Cannot get plugin version in web');
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,cAAc,GAAe;IACjC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,0BAA0B;IACtC,EAAE,EAAE,SAAS;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,KAAK,CAAC,QAAQ,CAAC,OAA0C;QACvD,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAuB;QAC/B,OAAO,CAAC,IAAI,CAAC,iCA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,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -34,7 +34,7 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
|
34
34
|
}
|
|
35
35
|
async getDeviceId() {
|
|
36
36
|
console.warn('Cannot get ID in web');
|
|
37
|
-
return {
|
|
37
|
+
return { deviceId: 'default' };
|
|
38
38
|
}
|
|
39
39
|
async getPluginVersion() {
|
|
40
40
|
console.warn('Cannot get plugin version in web');
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return {
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAA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/H,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACvD,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAClD,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -31,7 +31,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
31
31
|
}
|
|
32
32
|
async getDeviceId() {
|
|
33
33
|
console.warn('Cannot get ID in web');
|
|
34
|
-
return {
|
|
34
|
+
return { deviceId: 'default' };
|
|
35
35
|
}
|
|
36
36
|
async getPluginVersion() {
|
|
37
37
|
console.warn('Cannot get plugin version in web');
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return {
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICFD,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC,CAAC;IACK,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAChE,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,mBAAmB,GAAG;IAChC,QAAQ,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC9D,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClC,KAAK;IACL,IAAI,MAAM,GAAG,CAAC,OAAO,EAAE;IACvB,QAAQ,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;IACjE,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC7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AAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE;IACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/H,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;IACvD,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAClD,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -18,12 +18,14 @@ extension Date {
|
|
|
18
18
|
}
|
|
19
19
|
struct AppVersionDec: Decodable {
|
|
20
20
|
let version: String?
|
|
21
|
+
let checksum: String?
|
|
21
22
|
let url: String?
|
|
22
23
|
let message: String?
|
|
23
24
|
let major: Bool?
|
|
24
25
|
}
|
|
25
26
|
public class AppVersion: NSObject {
|
|
26
27
|
var version: String = ""
|
|
28
|
+
var checksum: String = ""
|
|
27
29
|
var url: String = ""
|
|
28
30
|
var message: String?
|
|
29
31
|
var major: Bool?
|
|
@@ -146,7 +148,7 @@ extension CustomError: LocalizedError {
|
|
|
146
148
|
|
|
147
149
|
public let TAG = "✨ Capacitor-updater:"
|
|
148
150
|
public let CAP_SERVER_PATH = "serverBasePath"
|
|
149
|
-
public let pluginVersion = "4.
|
|
151
|
+
public let pluginVersion = "4.4.1"
|
|
150
152
|
public var statsUrl = ""
|
|
151
153
|
public var appId = ""
|
|
152
154
|
public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
@@ -248,6 +250,9 @@ extension CustomError: LocalizedError {
|
|
|
248
250
|
if let url = response.value?.url {
|
|
249
251
|
latest.url = url
|
|
250
252
|
}
|
|
253
|
+
if let checksum = response.value?.checksum {
|
|
254
|
+
latest.checksum = checksum
|
|
255
|
+
}
|
|
251
256
|
if let version = response.value?.version {
|
|
252
257
|
latest.version = version
|
|
253
258
|
}
|
|
@@ -67,7 +67,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
67
67
|
let res = implementation.list()
|
|
68
68
|
res.forEach { version in
|
|
69
69
|
print("\(self.implementation.TAG) Deleting obsolete bundle: \(version)")
|
|
70
|
-
|
|
70
|
+
let res = implementation.delete(id: version.getId())
|
|
71
|
+
if !res {
|
|
72
|
+
print("\(self.implementation.TAG) Delete failed, id \(version.getId()) doesn't exist")
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
UserDefaults.standard.set( self.currentVersionNative.description, forKey: "LatestVersionNative")
|
|
@@ -465,6 +468,14 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
465
468
|
do {
|
|
466
469
|
print("\(self.implementation.TAG) New bundle: \(latestVersionName) found. Current is: \(current.getVersionName()). Update will occur next time app moves to background.")
|
|
467
470
|
let next = try self.implementation.download(url: downloadUrl, version: latestVersionName)
|
|
471
|
+
if res.checksum != "" && next.getChecksum() != res.checksum {
|
|
472
|
+
print("\(self.implementation.TAG) Error checksum", next.getChecksum(), res.checksum)
|
|
473
|
+
let resDel = self.implementation.delete(id: next.getId())
|
|
474
|
+
if !resDel {
|
|
475
|
+
print("\(self.implementation.TAG) Delete failed, id \(next.getId()) doesn't exist")
|
|
476
|
+
}
|
|
477
|
+
return
|
|
478
|
+
}
|
|
468
479
|
self.notifyListeners("updateAvailable", data: ["bundle": next.toJSON()])
|
|
469
480
|
_ = self.implementation.setNextBundle(next: next.getId())
|
|
470
481
|
} catch {
|
|
@@ -515,8 +526,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
515
526
|
}
|
|
516
527
|
|
|
517
528
|
}
|
|
518
|
-
|
|
519
|
-
@objc func appKilled(){
|
|
529
|
+
|
|
530
|
+
@objc func appKilled() {
|
|
520
531
|
self._checkCancelDelay(killed: true)
|
|
521
532
|
}
|
|
522
533
|
|