@capgo/capacitor-updater 7.38.0 → 7.39.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.
@@ -1146,6 +1146,150 @@ export interface CapacitorUpdaterPlugin {
1146
1146
  * @since 7.14.0
1147
1147
  */
1148
1148
  setAppId(options: SetAppIdOptions): Promise<void>;
1149
+ /**
1150
+ * Get information about the app's availability in the App Store or Play Store.
1151
+ *
1152
+ * This method checks the native app stores to see if a newer version of the app
1153
+ * is available for download. This is different from Capgo's OTA updates - this
1154
+ * checks for native app updates that require going through the app stores.
1155
+ *
1156
+ * **Platform differences:**
1157
+ * - **Android**: Uses Play Store's In-App Updates API for accurate update information
1158
+ * - **iOS**: Queries the App Store lookup API (requires country code for accurate results)
1159
+ *
1160
+ * **Returns information about:**
1161
+ * - Current installed version
1162
+ * - Available version in the store (if any)
1163
+ * - Whether an update is available
1164
+ * - Update priority (Android only)
1165
+ * - Whether immediate/flexible updates are allowed (Android only)
1166
+ *
1167
+ * Use this to:
1168
+ * - Check if users need to update from the app store
1169
+ * - Show "Update Available" prompts for native updates
1170
+ * - Implement version gating (require minimum native version)
1171
+ * - Combine with Capgo OTA updates for a complete update strategy
1172
+ *
1173
+ * @param options Optional {@link GetAppUpdateInfoOptions} with country code for iOS.
1174
+ * @returns {Promise<AppUpdateInfo>} Information about the current and available app versions.
1175
+ * @throws {Error} If the operation fails or store information is unavailable.
1176
+ * @since 8.0.0
1177
+ */
1178
+ getAppUpdateInfo(options?: GetAppUpdateInfoOptions): Promise<AppUpdateInfo>;
1179
+ /**
1180
+ * Open the app's page in the App Store or Play Store.
1181
+ *
1182
+ * This navigates the user to your app's store listing where they can manually
1183
+ * update the app. Use this as a fallback when in-app updates are not available
1184
+ * or when the user needs to update on iOS.
1185
+ *
1186
+ * **Platform behavior:**
1187
+ * - **Android**: Opens Play Store to the app's page
1188
+ * - **iOS**: Opens App Store to the app's page
1189
+ *
1190
+ * **Customization options:**
1191
+ * - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page
1192
+ * - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page
1193
+ *
1194
+ * @param options Optional {@link OpenAppStoreOptions} to customize which app's store page to open.
1195
+ * @returns {Promise<void>} Resolves when the store is opened.
1196
+ * @throws {Error} If the store cannot be opened.
1197
+ * @since 8.0.0
1198
+ */
1199
+ openAppStore(options?: OpenAppStoreOptions): Promise<void>;
1200
+ /**
1201
+ * Perform an immediate in-app update on Android.
1202
+ *
1203
+ * This triggers Google Play's immediate update flow, which:
1204
+ * 1. Shows a full-screen update UI
1205
+ * 2. Downloads and installs the update
1206
+ * 3. Restarts the app automatically
1207
+ *
1208
+ * The user cannot continue using the app until the update is complete.
1209
+ * This is ideal for critical updates that must be installed immediately.
1210
+ *
1211
+ * **Requirements:**
1212
+ * - Android only (throws error on iOS)
1213
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1214
+ * - The update must allow immediate updates (`immediateUpdateAllowed: true`)
1215
+ *
1216
+ * **User experience:**
1217
+ * - Full-screen blocking UI
1218
+ * - Progress shown during download
1219
+ * - App automatically restarts after installation
1220
+ *
1221
+ * @returns {Promise<AppUpdateResult>} Result indicating success, cancellation, or failure.
1222
+ * @throws {Error} If not on Android, no update is available, or immediate updates not allowed.
1223
+ * @since 8.0.0
1224
+ */
1225
+ performImmediateUpdate(): Promise<AppUpdateResult>;
1226
+ /**
1227
+ * Start a flexible in-app update on Android.
1228
+ *
1229
+ * This triggers Google Play's flexible update flow, which:
1230
+ * 1. Downloads the update in the background
1231
+ * 2. Allows the user to continue using the app
1232
+ * 3. Notifies when download is complete
1233
+ * 4. Requires calling {@link completeFlexibleUpdate} to install
1234
+ *
1235
+ * Monitor the download progress using the `onFlexibleUpdateStateChange` listener.
1236
+ *
1237
+ * **Requirements:**
1238
+ * - Android only (throws error on iOS)
1239
+ * - An update must be available (check with {@link getAppUpdateInfo} first)
1240
+ * - The update must allow flexible updates (`flexibleUpdateAllowed: true`)
1241
+ *
1242
+ * **Typical flow:**
1243
+ * 1. Call `startFlexibleUpdate()` to begin download
1244
+ * 2. Listen to `onFlexibleUpdateStateChange` for progress
1245
+ * 3. When status is `DOWNLOADED`, prompt user to restart
1246
+ * 4. Call `completeFlexibleUpdate()` to install and restart
1247
+ *
1248
+ * @returns {Promise<AppUpdateResult>} Result indicating the update was started, cancelled, or failed.
1249
+ * @throws {Error} If not on Android, no update is available, or flexible updates not allowed.
1250
+ * @since 8.0.0
1251
+ */
1252
+ startFlexibleUpdate(): Promise<AppUpdateResult>;
1253
+ /**
1254
+ * Complete a flexible in-app update on Android.
1255
+ *
1256
+ * After a flexible update has been downloaded (status `DOWNLOADED` in
1257
+ * `onFlexibleUpdateStateChange`), call this method to install the update
1258
+ * and restart the app.
1259
+ *
1260
+ * **Important:** This will immediately restart the app. Make sure to:
1261
+ * - Save any user data before calling
1262
+ * - Prompt the user before restarting
1263
+ * - Only call when the download status is `DOWNLOADED`
1264
+ *
1265
+ * @returns {Promise<void>} Resolves when the update installation begins (app will restart).
1266
+ * @throws {Error} If not on Android or no downloaded update is pending.
1267
+ * @since 8.0.0
1268
+ */
1269
+ completeFlexibleUpdate(): Promise<void>;
1270
+ /**
1271
+ * Listen for flexible update state changes on Android.
1272
+ *
1273
+ * This event fires during the flexible update download process, providing:
1274
+ * - Download progress (bytes downloaded / total bytes)
1275
+ * - Installation status changes
1276
+ *
1277
+ * **Install status values:**
1278
+ * - `UNKNOWN` (0): Unknown status
1279
+ * - `PENDING` (1): Download pending
1280
+ * - `DOWNLOADING` (2): Download in progress
1281
+ * - `INSTALLING` (3): Installing the update
1282
+ * - `INSTALLED` (4): Update installed (app restart needed)
1283
+ * - `FAILED` (5): Update failed
1284
+ * - `CANCELED` (6): Update was canceled
1285
+ * - `DOWNLOADED` (11): Download complete, ready to install
1286
+ *
1287
+ * When status is `DOWNLOADED`, you should prompt the user and call
1288
+ * {@link completeFlexibleUpdate} to finish the installation.
1289
+ *
1290
+ * @since 8.0.0
1291
+ */
1292
+ addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void): Promise<PluginListenerHandle>;
1149
1293
  }
1150
1294
  /**
1151
1295
  * pending: The bundle is pending to be **SET** as the next bundle.
@@ -1488,3 +1632,285 @@ export interface GetAppIdRes {
1488
1632
  export interface SetAppIdOptions {
1489
1633
  appId: string;
1490
1634
  }
1635
+ /**
1636
+ * Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.
1637
+ *
1638
+ * @since 8.0.0
1639
+ */
1640
+ export interface GetAppUpdateInfoOptions {
1641
+ /**
1642
+ * Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup.
1643
+ *
1644
+ * This is required on iOS to get accurate App Store information, as app
1645
+ * availability and versions can vary by country.
1646
+ *
1647
+ * Examples: "US", "GB", "DE", "JP", "FR"
1648
+ *
1649
+ * On Android, this option is ignored as the Play Store handles region
1650
+ * detection automatically.
1651
+ *
1652
+ * @since 8.0.0
1653
+ */
1654
+ country?: string;
1655
+ }
1656
+ /**
1657
+ * Information about app updates available in the App Store or Play Store.
1658
+ *
1659
+ * @since 8.0.0
1660
+ */
1661
+ export interface AppUpdateInfo {
1662
+ /**
1663
+ * The currently installed version name (e.g., "1.2.3").
1664
+ *
1665
+ * @since 8.0.0
1666
+ */
1667
+ currentVersionName: string;
1668
+ /**
1669
+ * The version name available in the store, if an update is available.
1670
+ * May be undefined if no update information is available.
1671
+ *
1672
+ * @since 8.0.0
1673
+ */
1674
+ availableVersionName?: string;
1675
+ /**
1676
+ * The currently installed version code (Android) or build number (iOS).
1677
+ *
1678
+ * @since 8.0.0
1679
+ */
1680
+ currentVersionCode: string;
1681
+ /**
1682
+ * The version code available in the store (Android only).
1683
+ * On iOS, this will be the same as `availableVersionName`.
1684
+ *
1685
+ * @since 8.0.0
1686
+ */
1687
+ availableVersionCode?: string;
1688
+ /**
1689
+ * The release date of the available version (iOS only).
1690
+ * Format: ISO 8601 date string.
1691
+ *
1692
+ * @since 8.0.0
1693
+ */
1694
+ availableVersionReleaseDate?: string;
1695
+ /**
1696
+ * The current update availability status.
1697
+ *
1698
+ * @since 8.0.0
1699
+ */
1700
+ updateAvailability: AppUpdateAvailability;
1701
+ /**
1702
+ * The priority of the update as set by the developer in Play Console (Android only).
1703
+ * Values range from 0 (default/lowest) to 5 (highest priority).
1704
+ *
1705
+ * Use this to decide whether to show an update prompt or force an update.
1706
+ *
1707
+ * @since 8.0.0
1708
+ */
1709
+ updatePriority?: number;
1710
+ /**
1711
+ * Whether an immediate update is allowed (Android only).
1712
+ *
1713
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}.
1714
+ *
1715
+ * @since 8.0.0
1716
+ */
1717
+ immediateUpdateAllowed?: boolean;
1718
+ /**
1719
+ * Whether a flexible update is allowed (Android only).
1720
+ *
1721
+ * If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}.
1722
+ *
1723
+ * @since 8.0.0
1724
+ */
1725
+ flexibleUpdateAllowed?: boolean;
1726
+ /**
1727
+ * Number of days since the update became available (Android only).
1728
+ *
1729
+ * Use this to implement "update nagging" - remind users more frequently
1730
+ * as the update ages.
1731
+ *
1732
+ * @since 8.0.0
1733
+ */
1734
+ clientVersionStalenessDays?: number;
1735
+ /**
1736
+ * The current install status of a flexible update (Android only).
1737
+ *
1738
+ * @since 8.0.0
1739
+ */
1740
+ installStatus?: FlexibleUpdateInstallStatus;
1741
+ /**
1742
+ * The minimum OS version required for the available update (iOS only).
1743
+ *
1744
+ * @since 8.0.0
1745
+ */
1746
+ minimumOsVersion?: string;
1747
+ }
1748
+ /**
1749
+ * Options for {@link CapacitorUpdaterPlugin.openAppStore}.
1750
+ *
1751
+ * @since 8.0.0
1752
+ */
1753
+ export interface OpenAppStoreOptions {
1754
+ /**
1755
+ * The Android package name to open in the Play Store.
1756
+ *
1757
+ * If not specified, uses the current app's package name.
1758
+ * Use this to open a different app's store page.
1759
+ *
1760
+ * Only used on Android.
1761
+ *
1762
+ * @since 8.0.0
1763
+ */
1764
+ packageName?: string;
1765
+ /**
1766
+ * The iOS App Store ID to open.
1767
+ *
1768
+ * If not specified, uses the current app's bundle identifier to look up the app.
1769
+ * Use this to open a different app's store page or when automatic lookup fails.
1770
+ *
1771
+ * Only used on iOS.
1772
+ *
1773
+ * @since 8.0.0
1774
+ */
1775
+ appId?: string;
1776
+ }
1777
+ /**
1778
+ * State information for flexible update progress (Android only).
1779
+ *
1780
+ * @since 8.0.0
1781
+ */
1782
+ export interface FlexibleUpdateState {
1783
+ /**
1784
+ * The current installation status.
1785
+ *
1786
+ * @since 8.0.0
1787
+ */
1788
+ installStatus: FlexibleUpdateInstallStatus;
1789
+ /**
1790
+ * Number of bytes downloaded so far.
1791
+ * Only available during the `DOWNLOADING` status.
1792
+ *
1793
+ * @since 8.0.0
1794
+ */
1795
+ bytesDownloaded?: number;
1796
+ /**
1797
+ * Total number of bytes to download.
1798
+ * Only available during the `DOWNLOADING` status.
1799
+ *
1800
+ * @since 8.0.0
1801
+ */
1802
+ totalBytesToDownload?: number;
1803
+ }
1804
+ /**
1805
+ * Result of an app update operation.
1806
+ *
1807
+ * @since 8.0.0
1808
+ */
1809
+ export interface AppUpdateResult {
1810
+ /**
1811
+ * The result code of the update operation.
1812
+ *
1813
+ * @since 8.0.0
1814
+ */
1815
+ code: AppUpdateResultCode;
1816
+ }
1817
+ /**
1818
+ * Update availability status.
1819
+ *
1820
+ * @since 8.0.0
1821
+ */
1822
+ export declare enum AppUpdateAvailability {
1823
+ /**
1824
+ * Update availability is unknown.
1825
+ * This typically means the check hasn't completed or failed.
1826
+ */
1827
+ UNKNOWN = 0,
1828
+ /**
1829
+ * No update is available.
1830
+ * The installed version is the latest.
1831
+ */
1832
+ UPDATE_NOT_AVAILABLE = 1,
1833
+ /**
1834
+ * An update is available for download.
1835
+ */
1836
+ UPDATE_AVAILABLE = 2,
1837
+ /**
1838
+ * An update is currently being downloaded or installed.
1839
+ */
1840
+ UPDATE_IN_PROGRESS = 3
1841
+ }
1842
+ /**
1843
+ * Installation status for flexible updates (Android only).
1844
+ *
1845
+ * @since 8.0.0
1846
+ */
1847
+ export declare enum FlexibleUpdateInstallStatus {
1848
+ /**
1849
+ * Unknown install status.
1850
+ */
1851
+ UNKNOWN = 0,
1852
+ /**
1853
+ * Download is pending and will start soon.
1854
+ */
1855
+ PENDING = 1,
1856
+ /**
1857
+ * Download is in progress.
1858
+ * Check `bytesDownloaded` and `totalBytesToDownload` for progress.
1859
+ */
1860
+ DOWNLOADING = 2,
1861
+ /**
1862
+ * The update is being installed.
1863
+ */
1864
+ INSTALLING = 3,
1865
+ /**
1866
+ * The update has been installed.
1867
+ * The app needs to be restarted to use the new version.
1868
+ */
1869
+ INSTALLED = 4,
1870
+ /**
1871
+ * The update failed to download or install.
1872
+ */
1873
+ FAILED = 5,
1874
+ /**
1875
+ * The update was canceled by the user.
1876
+ */
1877
+ CANCELED = 6,
1878
+ /**
1879
+ * The update has been downloaded and is ready to install.
1880
+ * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.
1881
+ */
1882
+ DOWNLOADED = 11
1883
+ }
1884
+ /**
1885
+ * Result codes for app update operations.
1886
+ *
1887
+ * @since 8.0.0
1888
+ */
1889
+ export declare enum AppUpdateResultCode {
1890
+ /**
1891
+ * The update completed successfully.
1892
+ */
1893
+ OK = 0,
1894
+ /**
1895
+ * The user canceled the update.
1896
+ */
1897
+ CANCELED = 1,
1898
+ /**
1899
+ * The update failed.
1900
+ */
1901
+ FAILED = 2,
1902
+ /**
1903
+ * No update is available.
1904
+ */
1905
+ NOT_AVAILABLE = 3,
1906
+ /**
1907
+ * The requested update type is not allowed.
1908
+ * For example, trying to perform an immediate update when only flexible is allowed.
1909
+ */
1910
+ NOT_ALLOWED = 4,
1911
+ /**
1912
+ * Required information is missing.
1913
+ * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.
1914
+ */
1915
+ INFO_MISSING = 5
1916
+ }
@@ -3,5 +3,107 @@
3
3
  * License, v. 2.0. If a copy of the MPL was not distributed with this
4
4
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- export {};
6
+ /**
7
+ * Update availability status.
8
+ *
9
+ * @since 8.0.0
10
+ */
11
+ export var AppUpdateAvailability;
12
+ (function (AppUpdateAvailability) {
13
+ /**
14
+ * Update availability is unknown.
15
+ * This typically means the check hasn't completed or failed.
16
+ */
17
+ AppUpdateAvailability[AppUpdateAvailability["UNKNOWN"] = 0] = "UNKNOWN";
18
+ /**
19
+ * No update is available.
20
+ * The installed version is the latest.
21
+ */
22
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_NOT_AVAILABLE"] = 1] = "UPDATE_NOT_AVAILABLE";
23
+ /**
24
+ * An update is available for download.
25
+ */
26
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_AVAILABLE"] = 2] = "UPDATE_AVAILABLE";
27
+ /**
28
+ * An update is currently being downloaded or installed.
29
+ */
30
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_IN_PROGRESS"] = 3] = "UPDATE_IN_PROGRESS";
31
+ })(AppUpdateAvailability || (AppUpdateAvailability = {}));
32
+ /**
33
+ * Installation status for flexible updates (Android only).
34
+ *
35
+ * @since 8.0.0
36
+ */
37
+ export var FlexibleUpdateInstallStatus;
38
+ (function (FlexibleUpdateInstallStatus) {
39
+ /**
40
+ * Unknown install status.
41
+ */
42
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["UNKNOWN"] = 0] = "UNKNOWN";
43
+ /**
44
+ * Download is pending and will start soon.
45
+ */
46
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["PENDING"] = 1] = "PENDING";
47
+ /**
48
+ * Download is in progress.
49
+ * Check `bytesDownloaded` and `totalBytesToDownload` for progress.
50
+ */
51
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["DOWNLOADING"] = 2] = "DOWNLOADING";
52
+ /**
53
+ * The update is being installed.
54
+ */
55
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["INSTALLING"] = 3] = "INSTALLING";
56
+ /**
57
+ * The update has been installed.
58
+ * The app needs to be restarted to use the new version.
59
+ */
60
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["INSTALLED"] = 4] = "INSTALLED";
61
+ /**
62
+ * The update failed to download or install.
63
+ */
64
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["FAILED"] = 5] = "FAILED";
65
+ /**
66
+ * The update was canceled by the user.
67
+ */
68
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["CANCELED"] = 6] = "CANCELED";
69
+ /**
70
+ * The update has been downloaded and is ready to install.
71
+ * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.
72
+ */
73
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["DOWNLOADED"] = 11] = "DOWNLOADED";
74
+ })(FlexibleUpdateInstallStatus || (FlexibleUpdateInstallStatus = {}));
75
+ /**
76
+ * Result codes for app update operations.
77
+ *
78
+ * @since 8.0.0
79
+ */
80
+ export var AppUpdateResultCode;
81
+ (function (AppUpdateResultCode) {
82
+ /**
83
+ * The update completed successfully.
84
+ */
85
+ AppUpdateResultCode[AppUpdateResultCode["OK"] = 0] = "OK";
86
+ /**
87
+ * The user canceled the update.
88
+ */
89
+ AppUpdateResultCode[AppUpdateResultCode["CANCELED"] = 1] = "CANCELED";
90
+ /**
91
+ * The update failed.
92
+ */
93
+ AppUpdateResultCode[AppUpdateResultCode["FAILED"] = 2] = "FAILED";
94
+ /**
95
+ * No update is available.
96
+ */
97
+ AppUpdateResultCode[AppUpdateResultCode["NOT_AVAILABLE"] = 3] = "NOT_AVAILABLE";
98
+ /**
99
+ * The requested update type is not allowed.
100
+ * For example, trying to perform an immediate update when only flexible is allowed.
101
+ */
102
+ AppUpdateResultCode[AppUpdateResultCode["NOT_ALLOWED"] = 4] = "NOT_ALLOWED";
103
+ /**
104
+ * Required information is missing.
105
+ * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.
106
+ */
107
+ AppUpdateResultCode[AppUpdateResultCode["INFO_MISSING"] = 5] = "INFO_MISSING";
108
+ })(AppUpdateResultCode || (AppUpdateResultCode = {}));
7
109
  //# sourceMappingURL=definitions.js.map