Skip to content

Commit 3169fb9

Browse files
committed
chore(live-update): native default channel is more important
1 parent c1264d1 commit 3169fb9

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

packages/live-update/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ We recommend to declare [`CA92.1`](https://developer.apple.com/documentation/bun
127127
| **`autoBlockRolledBackBundles`** | <code>boolean</code> | Whether or not to automatically block bundles that have been rolled back. When enabled, the plugin will automatically block bundles that caused a rollback (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked. Blocked bundles will be skipped in future sync operations. **Attention**: This option has no effect if `readyTimeout` is set to `0`. Only available on Android and iOS. | <code>false</code> | 7.3.0 |
128128
| **`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 |
129129
| **`autoUpdateStrategy`** | <code>'none' \| 'background'</code> | The auto-update strategy for live updates. - `none`: Live updates will not be applied automatically. - `background`: Live updates will be automatically downloaded and applied in the background at app startup and when the app resumes (if the last check was more than 15 minutes ago). Only available on Android and iOS. | <code>'none'</code> | 7.3.0 |
130-
| **`defaultChannel`** | <code>string</code> | The default channel of the app. This can be overridden by `setChannel()` or the `channel` parameter of `sync()`. It takes priority over the native channel configuration (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel` in `strings.xml` on Android). | | 6.3.0 |
130+
| **`defaultChannel`** | <code>string</code> | The default channel of the app. This can be overridden by `setChannel()`, the `channel` parameter of `sync()`, or the native channel configuration (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel` in `strings.xml` on Android). | | 6.3.0 |
131131
| **`httpTimeout`** | <code>number</code> | The timeout in milliseconds for HTTP requests. | <code>60000</code> | 6.4.0 |
132132
| **`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 |
133133
| **`readyTimeout`** | <code>number</code> | The timeout in milliseconds to wait for the app to be ready before resetting to the default bundle. It is strongly **recommended** to configure this option (e.g. `10000` ms) so that the plugin can roll back to the default bundle in case of problems. If configured, the plugin will wait for the app to call the `ready()` method before resetting to the default bundle. Set to `0` to disable the timeout. | <code>0</code> | 5.0.0 |
@@ -459,9 +459,9 @@ Get the channel that is used for the update.
459459

460460
The channel is resolved in the following order (highest priority first):
461461
1. `setChannel()` (SharedPreferences on Android / UserDefaults on iOS)
462-
2. Capacitor config `defaultChannel`
463-
3. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
462+
2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
464463
`capawesome_live_update_default_channel` in `strings.xml` on Android)
464+
3. Capacitor config `defaultChannel`
465465

466466
**Note**: The `channel` parameter of `sync()` takes the highest priority
467467
but is not persisted and therefore not returned by this method.
@@ -556,9 +556,9 @@ getDefaultChannel() => Promise<GetDefaultChannelResult>
556556
Get the default channel of the app.
557557

558558
The default channel is resolved in the following order (highest priority first):
559-
1. Capacitor config `defaultChannel`
560-
2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
559+
1. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
561560
`capawesome_live_update_default_channel` in `strings.xml` on Android)
561+
2. Capacitor config `defaultChannel`
562562

563563
Unlike `getChannel()`, this method does **not** include
564564
the channel set by `setChannel()`.

packages/live-update/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,13 +1028,13 @@ private String getChannel() {
10281028
@Nullable
10291029
private String getDefaultChannel() {
10301030
String channel = null;
1031+
if (config.getDefaultChannel() != null) {
1032+
channel = config.getDefaultChannel();
1033+
}
10311034
String nativeChannel = getNativeChannel();
10321035
if (nativeChannel != null) {
10331036
channel = nativeChannel;
10341037
}
1035-
if (config.getDefaultChannel() != null) {
1036-
channel = config.getDefaultChannel();
1037-
}
10381038
return channel;
10391039
}
10401040

packages/live-update/ios/Plugin/LiveUpdate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,12 @@ import CommonCrypto
615615

616616
private func getDefaultChannel() -> String? {
617617
var channel: String?
618-
if let nativeChannel = getNativeChannel() {
619-
channel = nativeChannel
620-
}
621618
if let _ = config.defaultChannel {
622619
channel = config.defaultChannel
623620
}
621+
if let nativeChannel = getNativeChannel() {
622+
channel = nativeChannel
623+
}
624624
return channel
625625
}
626626

packages/live-update/src/definitions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ declare module '@capacitor/cli' {
5757
/**
5858
* The default channel of the app.
5959
*
60-
* This can be overridden by `setChannel()` or the `channel` parameter of `sync()`.
61-
* It takes priority over the native channel configuration
60+
* This can be overridden by `setChannel()`, the `channel` parameter of `sync()`,
61+
* or the native channel configuration
6262
* (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel`
6363
* in `strings.xml` on Android).
6464
*
@@ -173,9 +173,9 @@ export interface LiveUpdatePlugin {
173173
*
174174
* The channel is resolved in the following order (highest priority first):
175175
* 1. `setChannel()` (SharedPreferences on Android / UserDefaults on iOS)
176-
* 2. Capacitor config `defaultChannel`
177-
* 3. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
176+
* 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
178177
* `capawesome_live_update_default_channel` in `strings.xml` on Android)
178+
* 3. Capacitor config `defaultChannel`
179179
*
180180
* **Note**: The `channel` parameter of `sync()` takes the highest priority
181181
* but is not persisted and therefore not returned by this method.
@@ -225,9 +225,9 @@ export interface LiveUpdatePlugin {
225225
* Get the default channel of the app.
226226
*
227227
* The default channel is resolved in the following order (highest priority first):
228-
* 1. Capacitor config `defaultChannel`
229-
* 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
228+
* 1. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
230229
* `capawesome_live_update_default_channel` in `strings.xml` on Android)
230+
* 2. Capacitor config `defaultChannel`
231231
*
232232
* Unlike `getChannel()`, this method does **not** include
233233
* the channel set by `setChannel()`.

0 commit comments

Comments
 (0)