@capawesome/capacitor-live-update 6.2.0 → 6.3.0
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 +3 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +22 -10
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +13 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +3 -1
- package/dist/docs.json +16 -0
- package/dist/esm/definitions.d.ts +7 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/LiveUpdate.swift +48 -20
- package/ios/Plugin/LiveUpdateConfig.swift +1 -0
- package/ios/Plugin/LiveUpdatePlugin.swift +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,7 @@ We recommend to declare [`CA92.1`](https://developer.apple.com/documentation/bun
|
|
|
69
69
|
| ----------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
|
|
70
70
|
| **`appId`** | <code>string</code> | The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud). | | 5.0.0 |
|
|
71
71
|
| **`autoDeleteBundles`** | <code>boolean</code> | Whether or not to automatically delete unused bundles. When enabled, the plugin will automatically delete unused bundles after calling `ready()`. | <code>false</code> | 5.0.0 |
|
|
72
|
+
| **`defaultChannel`** | <code>string</code> | The default channel of the app. | | 6.3.0 |
|
|
72
73
|
| **`enabled`** | <code>boolean</code> | Whether or not the plugin is enabled. | <code>true</code> | 5.0.0 |
|
|
73
74
|
| **`location`** | <code>'us' \| 'eu'</code> | The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud). | <code>'us'</code> | 6.2.0 |
|
|
74
75
|
| **`publicKey`** | <code>string</code> | The public key to verify the integrity of the bundle. The public key must be a PEM-encoded RSA public key. | | 6.1.0 |
|
|
@@ -85,6 +86,7 @@ In `capacitor.config.json`:
|
|
|
85
86
|
"LiveUpdate": {
|
|
86
87
|
"appId": '4100e356-e851-47fe-9d3c-b411eb325a99',
|
|
87
88
|
"autoDeleteBundles": undefined,
|
|
89
|
+
"defaultChannel": 'production',
|
|
88
90
|
"enabled": undefined,
|
|
89
91
|
"location": 'eu',
|
|
90
92
|
"publicKey": '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----',
|
|
@@ -107,6 +109,7 @@ const config: CapacitorConfig = {
|
|
|
107
109
|
LiveUpdate: {
|
|
108
110
|
appId: '4100e356-e851-47fe-9d3c-b411eb325a99',
|
|
109
111
|
autoDeleteBundles: undefined,
|
|
112
|
+
defaultChannel: 'production',
|
|
110
113
|
enabled: undefined,
|
|
111
114
|
location: 'eu',
|
|
112
115
|
publicKey: '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----',
|
|
@@ -133,7 +133,7 @@ public class LiveUpdate {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
public void getChannel(@NonNull NonEmptyCallback callback) {
|
|
136
|
-
String channel =
|
|
136
|
+
String channel = getChannel();
|
|
137
137
|
GetChannelResult result = new GetChannelResult(channel);
|
|
138
138
|
callback.success(result);
|
|
139
139
|
}
|
|
@@ -487,7 +487,7 @@ public class LiveUpdate {
|
|
|
487
487
|
.addQueryParameter("appVersionCode", getVersionCode())
|
|
488
488
|
.addQueryParameter("appVersionName", getVersionName())
|
|
489
489
|
.addQueryParameter("bundleId", getCurrentBundleId())
|
|
490
|
-
.addQueryParameter("channelName",
|
|
490
|
+
.addQueryParameter("channelName", getChannel())
|
|
491
491
|
.addQueryParameter("customId", preferences.getCustomId())
|
|
492
492
|
.addQueryParameter("deviceId", getDeviceId())
|
|
493
493
|
.addQueryParameter("osVersion", String.valueOf(Build.VERSION.SDK_INT))
|
|
@@ -530,14 +530,6 @@ public class LiveUpdate {
|
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
private String getVersionCode() throws PackageManager.NameNotFoundException {
|
|
534
|
-
return String.valueOf(getPackageInfo().versionCode);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
private String getVersionName() throws PackageManager.NameNotFoundException {
|
|
538
|
-
return getPackageInfo().versionName;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
533
|
private String[] getBundleIds() {
|
|
542
534
|
File bundlesDirectory = buildBundlesDirectory();
|
|
543
535
|
File[] bundles = bundlesDirectory.listFiles();
|
|
@@ -553,6 +545,18 @@ public class LiveUpdate {
|
|
|
553
545
|
return bundleIds;
|
|
554
546
|
}
|
|
555
547
|
|
|
548
|
+
@Nullable
|
|
549
|
+
private String getChannel() {
|
|
550
|
+
String channel = null;
|
|
551
|
+
if (config.getDefaultChannel() != null) {
|
|
552
|
+
channel = config.getDefaultChannel();
|
|
553
|
+
}
|
|
554
|
+
if (preferences.getChannel() != null) {
|
|
555
|
+
channel = preferences.getChannel();
|
|
556
|
+
}
|
|
557
|
+
return channel;
|
|
558
|
+
}
|
|
559
|
+
|
|
556
560
|
/**
|
|
557
561
|
* @return The current bundle ID (`public` for the built-in bundle).
|
|
558
562
|
*/
|
|
@@ -604,6 +608,14 @@ public class LiveUpdate {
|
|
|
604
608
|
.getString(WebView.CAP_SERVER_PATH, defaultWebAssetDir);
|
|
605
609
|
}
|
|
606
610
|
|
|
611
|
+
private String getVersionCode() throws PackageManager.NameNotFoundException {
|
|
612
|
+
return String.valueOf(getPackageInfo().versionCode);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
private String getVersionName() throws PackageManager.NameNotFoundException {
|
|
616
|
+
return getPackageInfo().versionName;
|
|
617
|
+
}
|
|
618
|
+
|
|
607
619
|
private boolean hasBundle(@NonNull String bundleId) {
|
|
608
620
|
File bundleDirectory = buildBundleDirectoryFor(bundleId);
|
|
609
621
|
return bundleDirectory.exists();
|
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java
CHANGED
|
@@ -9,6 +9,10 @@ public class LiveUpdateConfig {
|
|
|
9
9
|
private String appId = null;
|
|
10
10
|
|
|
11
11
|
private boolean autoDeleteBundles = false;
|
|
12
|
+
|
|
13
|
+
@Nullable
|
|
14
|
+
private String defaultChannel = null;
|
|
15
|
+
|
|
12
16
|
private boolean enabled = true;
|
|
13
17
|
|
|
14
18
|
@Nullable
|
|
@@ -29,6 +33,11 @@ public class LiveUpdateConfig {
|
|
|
29
33
|
return autoDeleteBundles;
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
@Nullable
|
|
37
|
+
public String getDefaultChannel() {
|
|
38
|
+
return defaultChannel;
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
public boolean getEnabled() {
|
|
33
42
|
return enabled;
|
|
34
43
|
}
|
|
@@ -59,6 +68,10 @@ public class LiveUpdateConfig {
|
|
|
59
68
|
this.autoDeleteBundles = autoDeleteBundles;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
public void setDefaultChannel(@Nullable String defaultChannel) {
|
|
72
|
+
this.defaultChannel = defaultChannel;
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
public void setEnabled(boolean enabled) {
|
|
63
76
|
this.enabled = enabled;
|
|
64
77
|
}
|
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java
CHANGED
|
@@ -19,7 +19,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
|
19
19
|
public class LiveUpdatePlugin extends Plugin {
|
|
20
20
|
|
|
21
21
|
public static final String TAG = "LiveUpdate";
|
|
22
|
-
public static final String VERSION = "6.
|
|
22
|
+
public static final String VERSION = "6.3.0";
|
|
23
23
|
public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
|
|
24
24
|
public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
|
|
25
25
|
public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
|
|
@@ -431,6 +431,8 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
431
431
|
config.setAppId(appId);
|
|
432
432
|
boolean autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.getAutoDeleteBundles());
|
|
433
433
|
config.setAutoDeleteBundles(autoDeleteBundles);
|
|
434
|
+
String defaultChannel = getConfig().getString("defaultChannel", config.getDefaultChannel());
|
|
435
|
+
config.setDefaultChannel(defaultChannel);
|
|
434
436
|
boolean enabled = getConfig().getBoolean("enabled", config.getEnabled());
|
|
435
437
|
config.setEnabled(enabled);
|
|
436
438
|
String location = getConfig().getString("location", config.getLocation());
|
package/dist/docs.json
CHANGED
|
@@ -746,6 +746,22 @@
|
|
|
746
746
|
"complexTypes": [],
|
|
747
747
|
"type": "boolean | undefined"
|
|
748
748
|
},
|
|
749
|
+
{
|
|
750
|
+
"name": "defaultChannel",
|
|
751
|
+
"tags": [
|
|
752
|
+
{
|
|
753
|
+
"text": "6.3.0",
|
|
754
|
+
"name": "since"
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
"text": "'production'",
|
|
758
|
+
"name": "example"
|
|
759
|
+
}
|
|
760
|
+
],
|
|
761
|
+
"docs": "The default channel of the app.",
|
|
762
|
+
"complexTypes": [],
|
|
763
|
+
"type": "string | undefined"
|
|
764
|
+
},
|
|
749
765
|
{
|
|
750
766
|
"name": "enabled",
|
|
751
767
|
"tags": [
|
|
@@ -17,6 +17,13 @@ declare module '@capacitor/cli' {
|
|
|
17
17
|
* @default false
|
|
18
18
|
*/
|
|
19
19
|
autoDeleteBundles?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The default channel of the app.
|
|
22
|
+
*
|
|
23
|
+
* @since 6.3.0
|
|
24
|
+
* @example 'production'
|
|
25
|
+
*/
|
|
26
|
+
defaultChannel?: string;
|
|
20
27
|
/**
|
|
21
28
|
* Whether or not the plugin is enabled.
|
|
22
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 5.0.0\n * @example '4100e356-e851-47fe-9d3c-b411eb325a99'\n */\n appId?: string;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * Whether or not the plugin is enabled.\n *\n * @since 5.0.0\n * @default true\n */\n enabled?: boolean;\n /**\n * The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 6.2.0\n * @default 'us'\n * @example 'eu'\n * @see https://capawesome.io/cloud/live-updates/advanced/privacy/\n */\n location?: 'us' | 'eu';\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready before resetting to the default bundle.\n *\n * @since 5.0.0\n * @default 10000\n */\n readyTimeout?: number;\n /**\n * Whether or not the app should be reset to the default bundle during an update.\n *\n * @since 5.0.0\n * @default true\n */\n resetOnUpdate?: boolean;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Get the active bundle identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundle(): Promise<GetBundleResult>;\n /**\n * Get all available bundle identifiers.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the device identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the version code of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<void>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setBundle(options: SetBundleOptions): Promise<void>;\n /**\n * Set the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(): Promise<SyncResult>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The unique identifier of the bundle.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the bundle to verify the integrity of the ZIP file.\n *\n * Must be a SHA-256 hash in hexadecimal format.\n *\n * @since 6.1.0\n * @example 'aab8e0a312e807c8eaeb923e2bdccd7731c5508869c62ad8e6e43ee881414c84'\n */\n checksum?: string;\n /**\n * The URL of the bundle to download.\n *\n * The bundle must be a ZIP file containing at least a `index.html` file.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel of the app.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the app.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel of the app.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the app.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 5.0.0\n * @example '4100e356-e851-47fe-9d3c-b411eb325a99'\n */\n appId?: string;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * The default channel of the app.\n *\n * @since 6.3.0\n * @example 'production'\n */\n defaultChannel?: string;\n /**\n * Whether or not the plugin is enabled.\n *\n * @since 5.0.0\n * @default true\n */\n enabled?: boolean;\n /**\n * The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 6.2.0\n * @default 'us'\n * @example 'eu'\n * @see https://capawesome.io/cloud/live-updates/advanced/privacy/\n */\n location?: 'us' | 'eu';\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready before resetting to the default bundle.\n *\n * @since 5.0.0\n * @default 10000\n */\n readyTimeout?: number;\n /**\n * Whether or not the app should be reset to the default bundle during an update.\n *\n * @since 5.0.0\n * @default true\n */\n resetOnUpdate?: boolean;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Get the active bundle identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundle(): Promise<GetBundleResult>;\n /**\n * Get all available bundle identifiers.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the device identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the version code of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<void>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setBundle(options: SetBundleOptions): Promise<void>;\n /**\n * Set the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(): Promise<SyncResult>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The unique identifier of the bundle.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the bundle to verify the integrity of the ZIP file.\n *\n * Must be a SHA-256 hash in hexadecimal format.\n *\n * @since 6.1.0\n * @example 'aab8e0a312e807c8eaeb923e2bdccd7731c5508869c62ad8e6e43ee881414c84'\n */\n checksum?: string;\n /**\n * The URL of the bundle to download.\n *\n * The bundle must be a ZIP file containing at least a `index.html` file.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel of the app.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the app.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel of the app.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the app.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n"]}
|
|
@@ -89,7 +89,7 @@ import CommonCrypto
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
@objc public func getChannel(completion: @escaping (Result?, Error?) -> Void) {
|
|
92
|
-
let channel =
|
|
92
|
+
let channel = getChannel()
|
|
93
93
|
let result = GetChannelResult(channel: channel)
|
|
94
94
|
completion(result, nil)
|
|
95
95
|
}
|
|
@@ -372,7 +372,7 @@ import CommonCrypto
|
|
|
372
372
|
parameters["appVersionCode"] = getVersionCode()
|
|
373
373
|
parameters["appVersionName"] = getVersionName()
|
|
374
374
|
parameters["bundleId"] = getCurrentBundleId()
|
|
375
|
-
parameters["channelName"] =
|
|
375
|
+
parameters["channelName"] = getChannel()
|
|
376
376
|
parameters["customId"] = preferences.getCustomId()
|
|
377
377
|
parameters["deviceId"] = getDeviceId()
|
|
378
378
|
parameters["osVersion"] = UIDevice.current.systemVersion
|
|
@@ -399,20 +399,6 @@ import CommonCrypto
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
private func getVersionCode() -> String {
|
|
403
|
-
guard let appVersionCode = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
|
|
404
|
-
return ""
|
|
405
|
-
}
|
|
406
|
-
return appVersionCode
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
private func getVersionName() -> String {
|
|
410
|
-
guard let appVersionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
|
|
411
|
-
return ""
|
|
412
|
-
}
|
|
413
|
-
return appVersionName
|
|
414
|
-
}
|
|
415
|
-
|
|
416
402
|
private func getBundleIds() -> [String] {
|
|
417
403
|
let url = libraryDirectoryUrl.appendingPathComponent(bundlesDirectory)
|
|
418
404
|
do {
|
|
@@ -427,6 +413,17 @@ import CommonCrypto
|
|
|
427
413
|
}
|
|
428
414
|
}
|
|
429
415
|
|
|
416
|
+
private func getChannel() -> String? {
|
|
417
|
+
var channel: String?
|
|
418
|
+
if let _ = config.defaultChannel {
|
|
419
|
+
channel = config.defaultChannel
|
|
420
|
+
}
|
|
421
|
+
if let _ = preferences.getChannel() {
|
|
422
|
+
channel = preferences.getChannel()
|
|
423
|
+
}
|
|
424
|
+
return channel
|
|
425
|
+
}
|
|
426
|
+
|
|
430
427
|
/// - Returns: The current bundle ID (`public` for the built-in bundle) or `nil` if no view controller was found.
|
|
431
428
|
private func getCurrentBundleId() -> String? {
|
|
432
429
|
guard let path = getCurrentCapacitorServerPath() else {
|
|
@@ -463,6 +460,20 @@ import CommonCrypto
|
|
|
463
460
|
return defaultCapacitorServerPath
|
|
464
461
|
}
|
|
465
462
|
|
|
463
|
+
private func getVersionCode() -> String {
|
|
464
|
+
guard let appVersionCode = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
|
|
465
|
+
return ""
|
|
466
|
+
}
|
|
467
|
+
return appVersionCode
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
private func getVersionName() -> String {
|
|
471
|
+
guard let appVersionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
|
|
472
|
+
return ""
|
|
473
|
+
}
|
|
474
|
+
return appVersionName
|
|
475
|
+
}
|
|
476
|
+
|
|
466
477
|
private func hasBundle(bundleId: String) -> Bool {
|
|
467
478
|
let path = buildBundlePathFor(bundleId: bundleId)
|
|
468
479
|
return FileManager.default.fileExists(atPath: path)
|
|
@@ -486,11 +497,28 @@ import CommonCrypto
|
|
|
486
497
|
}
|
|
487
498
|
|
|
488
499
|
private func searchIndexHtmlFile(url: URL) -> URL? {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
if
|
|
492
|
-
return
|
|
500
|
+
do {
|
|
501
|
+
let directoryContents = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: [])
|
|
502
|
+
if directoryContents.isEmpty {
|
|
503
|
+
return nil
|
|
493
504
|
}
|
|
505
|
+
let fileNames = directoryContents.map { $0.lastPathComponent }
|
|
506
|
+
if fileNames.contains("index.html") {
|
|
507
|
+
return url.appendingPathComponent("index.html")
|
|
508
|
+
} else {
|
|
509
|
+
for fileUrl in directoryContents {
|
|
510
|
+
var isDirectory: ObjCBool = false
|
|
511
|
+
if FileManager.default.fileExists(atPath: fileUrl.path, isDirectory: &isDirectory) {
|
|
512
|
+
if isDirectory.boolValue {
|
|
513
|
+
if let indexHtmlFile = searchIndexHtmlFile(url: fileUrl) {
|
|
514
|
+
return indexHtmlFile
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
} catch {
|
|
521
|
+
CAPLog.print("[", LiveUpdatePlugin.tag, "] ", "Failed to search index.html file: \(error.localizedDescription)")
|
|
494
522
|
}
|
|
495
523
|
return nil
|
|
496
524
|
}
|
|
@@ -8,7 +8,7 @@ import Capacitor
|
|
|
8
8
|
@objc(LiveUpdatePlugin)
|
|
9
9
|
public class LiveUpdatePlugin: CAPPlugin {
|
|
10
10
|
public static let tag = "LiveUpdate"
|
|
11
|
-
public static let version = "6.
|
|
11
|
+
public static let version = "6.3.0"
|
|
12
12
|
public static let userDefaultsPrefix = "CapawesomeLiveUpdate" // DO NOT CHANGE
|
|
13
13
|
|
|
14
14
|
private var config: LiveUpdateConfig?
|
|
@@ -239,6 +239,7 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
239
239
|
|
|
240
240
|
config.appId = getConfig().getString("appId", config.appId)
|
|
241
241
|
config.autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.autoDeleteBundles)
|
|
242
|
+
config.defaultChannel = getConfig().getString("defaultChannel", config.defaultChannel)
|
|
242
243
|
config.enabled = getConfig().getBoolean("enabled", config.enabled)
|
|
243
244
|
config.location = getConfig().getString("location", config.location)
|
|
244
245
|
config.publicKey = getConfig().getString("publicKey", config.publicKey)
|