A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Cap-go/capacitor-updater below:

Cap-go/capacitor-updater: Capacitor plugin for Instant updates: Ship updates, fixes, changes, and features within minutes

Capacitor plugin to update your app remotely in real-time.

Open-source Alternative to Appflow, Codepush or Capawesome

You have 3 ways possible :

The most complete documentation here.

Join the discord to get help.

Plugin version Capacitor compatibility Maintained v7.*.* v7.*.* ✅ v6.*.* v6.*.* Critical bug only v5.*.* v5.*.* ⚠️ Deprecated v4.*.* v4.*.* ⚠️ Deprecated v3.*.* v3.*.* ⚠️ Deprecated > 7 v4.*.* ⚠️ Deprecated, our CI got crazy and bumped too much version

Add the NSPrivacyAccessedAPICategoryUserDefaults dictionary key to your Privacy Manifest (usually ios/App/PrivacyInfo.xcprivacy):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>NSPrivacyAccessedAPITypes</key>
    <array>
      <!-- Add this dict entry to the array if the file already exists. -->
      <dict>
        <key>NSPrivacyAccessedAPIType</key>
        <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
        <key>NSPrivacyAccessedAPITypeReasons</key>
        <array>
          <string>CA92.1</string>
        </array>
      </dict>
    </array>
  </dict>
</plist>

We recommend to declare CA92.1 as the reason for accessing the UserDefaults API.

Step by step here: Getting started

Or

npm install @capgo/capacitor-updater
npx cap sync

Create your account in capgo.app and get your API key

For detailed instructions on the auto-update setup, refer to the Auto update documentation.

Download update distribution zipfiles from a custom URL. Manually control the entire update process.

// capacitor.config.json
{
	"appId": "**.***.**",
	"appName": "Name",
	"plugins": {
		"CapacitorUpdater": {
			"autoUpdate": false,
		}
	}
}
  import { CapacitorUpdater } from '@capgo/capacitor-updater'
  CapacitorUpdater.notifyAppReady()

This informs Capacitor Updater that the current update bundle has loaded succesfully. Failing to call this method will cause your application to be rolled back to the previously successful version (or built-in bundle).

  const version = await CapacitorUpdater.download({
    version: '0.0.4',
    url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
  })
  await CapacitorUpdater.set(version); // sets the new version, and reloads the app
  import { CapacitorUpdater, VersionInfo } from '@capgo/capacitor-updater'
  import { SplashScreen } from '@capacitor/splash-screen'
  import { App } from '@capacitor/app'

  let version: VersionInfo;
  App.addListener('appStateChange', async (state) => {
      if (state.isActive) {
        // Ensure download occurs while the app is active, or download may fail
        version = await CapacitorUpdater.download({
          version: '0.0.4',
          url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
        })
      }

      if (!state.isActive && version) {
        // Activate the update when the application is sent to background
        SplashScreen.show()
        try {
          await CapacitorUpdater.set(version);
          // At this point, the new version should be active, and will need to hide the splash screen
        } catch () {
          SplashScreen.hide() // Hide the splash screen again if something went wrong
        }
      }
  })

TIP: If you prefer a secure and automated way to update your app, you can use capgo.app - a full-featured, auto-update system.

Store Guideline Compliance

Android Google Play and iOS App Store have corresponding guidelines that have rules you should be aware of before integrating the Capacitor-updater solution within your application.

Third paragraph of Device and Network Abuse topic describe that updating source code by any method besides Google Play's update mechanism is restricted. But this restriction does not apply to updating JavaScript bundles.

This restriction does not apply to code that runs in a virtual machine and has limited access to Android APIs (such as JavaScript in a web view or browser).

That fully allow Capacitor-updater as it updates just JS bundles and can't update native code part.

Paragraph 3.3.2, since back in 2015's Apple Developer Program License Agreement fully allowed performing over-the-air updates of JavaScript and assets.

And in its latest version (20170605) downloadable here this ruling is even broader:

Interpreted code may be downloaded to an Application, but only so long as such code:

Capacitor-updater allows you to respect these rules in full compliance, so long as the update you push does not significantly deviate your product from its original App Store approved intent.

To further remain in compliance with Apple's guidelines, we suggest that App Store-distributed apps don't enable the Force update scenario, since in the App Store Review Guidelines it is written that:

Apps must not force users to rate the app, review the app, download other apps, or other similar actions to access functionality, content, or use of the app.

This is not a problem for the default behavior of background update, since it won't force the user to apply the new version until the next app close, but at least you should be aware of that ruling if you decide to show it.

Packaging dist.zip update bundles

Capacitor Updater works by unzipping a compiled app bundle to the native device filesystem. Whatever you choose to name the file you upload/download from your release/update server URL (via either manual or automatic updating), this .zip bundle must meet the following requirements:

CapacitorUpdater can be configured with these options:

Prop Type Description Default Since appReadyTimeout number Configure the number of milliseconds the native plugin should wait before considering an update 'failed'. Only available for Android and iOS. 10000 // (10 seconds) responseTimeout number Configure the number of seconds the native plugin should wait before considering API timeout. Only available for Android and iOS. 20 // (20 second) autoDeleteFailed boolean Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. true autoDeletePrevious boolean Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. true autoUpdate boolean Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS. true resetWhenUpdate boolean Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Only available for Android and iOS. true updateUrl string Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. https://plugin.capgo.app/updates channelUrl string Configure the URL / endpoint for channel operations. Only available for Android and iOS. https://plugin.capgo.app/channel_self statsUrl string Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. https://plugin.capgo.app/stats publicKey string Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. undefined 6.2.0 version string Configure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS. undefined 4.17.48 directUpdate boolean | 'always' | 'atInstall' Configure when the plugin should direct install updates. Only for autoUpdate mode. Works well for apps less than 10MB and with uploads done using --partial flag. Zip or apps more than 10MB will be relatively slow for users to update. - false: Never do direct updates (default behavior) - atInstall: Direct update only when app is installed/updated from store, otherwise use normal background update - always: Always do direct updates immediately when available - true: (deprecated) Same as "always" for backward compatibility Only available for Android and iOS. false 5.1.0 autoSplashscreen boolean Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed. This removes the need to manually listen for appReady events and call SplashScreen.hide(). Only works when directUpdate is set to "atInstall", "always", or true. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Requires autoUpdate and directUpdate to be enabled. Only available for Android and iOS. false 7.6.0 periodCheckDelay number Configure the delay period for period update check. the unit is in seconds. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes). 600 // (10 minutes) localS3 boolean Configure the CLI to use a local server for testing or self-hosted update server. undefined 4.17.48 localHost string Configure the CLI to use a local server for testing or self-hosted update server. undefined 4.17.48 localWebHost string Configure the CLI to use a local server for testing or self-hosted update server. undefined 4.17.48 localSupa string Configure the CLI to use a local server for testing or self-hosted update server. undefined 4.17.48 localSupaAnon string Configure the CLI to use a local server for testing. undefined 4.17.48 localApi string Configure the CLI to use a local api for testing. undefined 6.3.3 localApiFiles string Configure the CLI to use a local file api for testing. undefined 6.3.3 allowModifyUrl boolean Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. false 5.4.0 defaultChannel string Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. undefined 5.5.0 appId string Configure the app id for the app in the config. undefined 6.0.0 keepUrlPathAfterReload boolean Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. false 6.8.0 disableJSLogging boolean Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done false 7.3.0 shakeMenu boolean Enable shake gesture to show update menu for debugging/testing purposes false 7.5.0

In capacitor.config.json:

{
  "plugins": {
    "CapacitorUpdater": {
      "appReadyTimeout": 1000 // (1 second),
      "responseTimeout": 10 // (10 second),
      "autoDeleteFailed": false,
      "autoDeletePrevious": false,
      "autoUpdate": false,
      "resetWhenUpdate": false,
      "updateUrl": https://example.com/api/auto_update,
      "channelUrl": https://example.com/api/channel,
      "statsUrl": https://example.com/api/stats,
      "publicKey": undefined,
      "version": undefined,
      "directUpdate": undefined,
      "autoSplashscreen": undefined,
      "periodCheckDelay": undefined,
      "localS3": undefined,
      "localHost": undefined,
      "localWebHost": undefined,
      "localSupa": undefined,
      "localSupaAnon": undefined,
      "localApi": undefined,
      "localApiFiles": undefined,
      "allowModifyUrl": undefined,
      "defaultChannel": undefined,
      "appId": undefined,
      "keepUrlPathAfterReload": undefined,
      "disableJSLogging": undefined,
      "shakeMenu": undefined
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capgo/capacitor-updater" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    CapacitorUpdater: {
      appReadyTimeout: 1000 // (1 second),
      responseTimeout: 10 // (10 second),
      autoDeleteFailed: false,
      autoDeletePrevious: false,
      autoUpdate: false,
      resetWhenUpdate: false,
      updateUrl: https://example.com/api/auto_update,
      channelUrl: https://example.com/api/channel,
      statsUrl: https://example.com/api/stats,
      publicKey: undefined,
      version: undefined,
      directUpdate: undefined,
      autoSplashscreen: undefined,
      periodCheckDelay: undefined,
      localS3: undefined,
      localHost: undefined,
      localWebHost: undefined,
      localSupa: undefined,
      localSupaAnon: undefined,
      localApi: undefined,
      localApiFiles: undefined,
      allowModifyUrl: undefined,
      defaultChannel: undefined,
      appId: undefined,
      keepUrlPathAfterReload: undefined,
      disableJSLogging: undefined,
      shakeMenu: undefined,
    },
  },
};

export default config;
notifyAppReady() => Promise<AppReadyResult>

Notify Capacitor Updater that the current bundle is working (a rollback will occur if this method is not called on every app launch) By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur. Change this behaviour with {@link appReadyTimeout}

Returns: Promise<AppReadyResult>

setUpdateUrl(options: UpdateUrl) => Promise<void>

Set the updateUrl for the app, this will be used to check for updates.

Param Type Description options UpdateUrl contains the URL to use for checking for updates.

Since: 5.4.0

setStatsUrl(options: StatsUrl) => Promise<void>

Set the statsUrl for the app, this will be used to send statistics. Passing an empty string will disable statistics gathering.

Param Type Description options StatsUrl contains the URL to use for sending statistics.

Since: 5.4.0

setChannelUrl(options: ChannelUrl) => Promise<void>

Set the channelUrl for the app, this will be used to set the channel.

Param Type Description options ChannelUrl contains the URL to use for setting the channel.

Since: 5.4.0

download(options: DownloadOptions) => Promise<BundleInfo>

Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files

Returns: Promise<BundleInfo>

next(options: BundleId) => Promise<BundleInfo>

Set the next bundle to be used when the app is reloaded.

Param Type Description options BundleId Contains the ID of the next Bundle to set on next app launch. {@link BundleInfo.id}

Returns: Promise<BundleInfo>

set(options: BundleId) => Promise<void>

Set the current bundle and immediately reloads the app.

Param Type Description options BundleId A {@link BundleId} object containing the new bundle id to set as current.
delete(options: BundleId) => Promise<void>

Deletes the specified bundle from the native app storage. Use with {@link list} to get the stored Bundle IDs.

Param Type Description options BundleId A {@link BundleId} object containing the ID of a bundle to delete (note, this is the bundle id, NOT the version name)
list(options?: ListOptions | undefined) => Promise<BundleListResult>

Get all locally downloaded bundles in your app

Returns: Promise<BundleListResult>

reset(options?: ResetOptions | undefined) => Promise<void>

Reset the app to the builtin bundle (the one sent to Apple App Store / Google Play Store ) or the last successfully loaded bundle.

current() => Promise<CurrentBundleResult>

Get the current bundle, if none are set it returns builtin. currentNative is the original bundle installed on the device

Returns: Promise<CurrentBundleResult>

reload() => Promise<void>

Reload the view

setMultiDelay(options: MultiDelayConditions) => Promise<void>

Sets a {@link DelayCondition} array containing conditions that the Plugin will use to delay the update. After all conditions are met, the update process will run start again as usual, so update will be installed after a backgrounding or killing the app. For the date kind, the value should be an iso8601 date string. For the background kind, the value should be a number in milliseconds. For the nativeVersion kind, the value should be the version number. For the kill kind, the value is not used. The function has unconsistent behavior the option kill do trigger the update after the first kill and not after the next background like other options. This will be fixed in a future major release.

Since: 4.3.0

cancelDelay() => Promise<void>

Cancels a {@link DelayCondition} to process an update immediately.

Since: 4.0.0

getLatest(options?: GetLatestOptions | undefined) => Promise<LatestVersion>

Get Latest bundle available from update Url

Returns: Promise<LatestVersion>

Since: 4.0.0

setChannel(options: SetChannelOptions) => Promise<ChannelRes>

Sets the channel for this device. The channel has to allow for self assignment for this to work. Do not use this method to set the channel at boot. This method is to set the channel after the app is ready, and user interacted. If you want to set the channel at boot, use the {@link PluginsConfig} to set the default channel. This methods send to Capgo backend a request to link the device ID to the channel. Capgo can accept or refuse depending of the setting of your channel.

Returns: Promise<ChannelRes>

Since: 4.7.0

unsetChannel(options: UnsetChannelOptions) => Promise<void>

Unset the channel for this device. The device will then return to the default channel

Since: 4.7.0

getChannel() => Promise<GetChannelRes>

Get the channel for this device

Returns: Promise<GetChannelRes>

Since: 4.8.0

listChannels() => Promise<ListChannelsResult>

List all channels available for this device that allow self-assignment

Returns: Promise<ListChannelsResult>

Since: 7.5.0

setCustomId(options: SetCustomIdOptions) => Promise<void>

Set a custom ID for this device

Since: 4.9.0

getBuiltinVersion() => Promise<BuiltinVersion>

Get the native app version or the builtin version if set in config

Returns: Promise<BuiltinVersion>

Since: 5.2.0

getDeviceId() => Promise<DeviceId>

Get unique ID used to identify device (sent to auto update server)

Returns: Promise<DeviceId>

getPluginVersion() => Promise<PluginVersion>

Get the native Capacitor Updater plugin version (sent to auto update server)

Returns: Promise<PluginVersion>

isAutoUpdateEnabled() => Promise<AutoUpdateEnabled>

Get the state of auto update config.

Returns: Promise<AutoUpdateEnabled>

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 1.0.0

addListener('download', ...)
addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void) => Promise<PluginListenerHandle>

Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished. This will return you all download percent during the download

Param Type eventName 'download' listenerFunc (state: DownloadEvent) => void

Returns: Promise<PluginListenerHandle>

Since: 2.0.11

addListener('noNeedUpdate', ...)
addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void) => Promise<PluginListenerHandle>

Listen for no need to update event, useful when you want force check every time the app is launched

Param Type eventName 'noNeedUpdate' listenerFunc (state: NoNeedEvent) => void

Returns: Promise<PluginListenerHandle>

Since: 4.0.0

addListener('updateAvailable', ...)
addListener(eventName: 'updateAvailable', listenerFunc: (state: UpdateAvailableEvent) => void) => Promise<PluginListenerHandle>

Listen for available update event, useful when you want to force check every time the app is launched

Returns: Promise<PluginListenerHandle>

Since: 4.0.0

addListener('downloadComplete', ...)
addListener(eventName: 'downloadComplete', listenerFunc: (state: DownloadCompleteEvent) => void) => Promise<PluginListenerHandle>

Listen for downloadComplete events.

Returns: Promise<PluginListenerHandle>

Since: 4.0.0

addListener('majorAvailable', ...)
addListener(eventName: 'majorAvailable', listenerFunc: (state: MajorAvailableEvent) => void) => Promise<PluginListenerHandle>

Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking

Returns: Promise<PluginListenerHandle>

Since: 2.3.0

addListener('updateFailed', ...)
addListener(eventName: 'updateFailed', listenerFunc: (state: UpdateFailedEvent) => void) => Promise<PluginListenerHandle>

Listen for update fail event in the App, let you know when update has fail to install at next app start

Returns: Promise<PluginListenerHandle>

Since: 2.3.0

addListener('downloadFailed', ...)
addListener(eventName: 'downloadFailed', listenerFunc: (state: DownloadFailedEvent) => void) => Promise<PluginListenerHandle>

Listen for download fail event in the App, let you know when a bundle download has failed

Returns: Promise<PluginListenerHandle>

Since: 4.0.0

addListener('appReloaded', ...)
addListener(eventName: 'appReloaded', listenerFunc: () => void) => Promise<PluginListenerHandle>

Listen for reload event in the App, let you know when reload has happened

Param Type eventName 'appReloaded' listenerFunc () => void

Returns: Promise<PluginListenerHandle>

Since: 4.3.0

addListener('appReady', ...)
addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void) => Promise<PluginListenerHandle>

Listen for app ready event in the App, let you know when app is ready to use

Param Type eventName 'appReady' listenerFunc (state: AppReadyEvent) => void

Returns: Promise<PluginListenerHandle>

Since: 5.1.0

isAutoUpdateAvailable() => Promise<AutoUpdateAvailable>

Get if auto update is available (not disabled by serverUrl).

Returns: Promise<AutoUpdateAvailable>

getNextBundle() => Promise<BundleInfo | null>

Get the next bundle that will be used when the app reloads. Returns null if no next bundle is set.

Returns: Promise<BundleInfo | null>

Since: 6.8.0

setShakeMenu(options: SetShakeMenuOptions) => Promise<void>

Enable or disable the shake menu for debugging/testing purposes

Param Type Description options SetShakeMenuOptions Contains enabled boolean to enable or disable shake menu

Since: 7.5.0

isShakeMenuEnabled() => Promise<ShakeMenuEnabled>

Get the current state of the shake menu

Returns: Promise<ShakeMenuEnabled>

Since: 7.5.0

Prop Type id string version string downloaded string checksum string status BundleStatus

This URL and versions are used to download the bundle from the server, If you use backend all information will be gived by the method getLatest. If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.

Prop Type Description Default Since url string The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.) version string The version code/name of this bundle/version sessionKey string The session key for the update, when the bundle is encrypted with a session key undefined 4.0.0 checksum string The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted undefined 4.0.0 manifest ManifestEntry[] The manifest for multi-file downloads undefined 6.1.0 Prop Type file_name string | null file_hash string | null download_url string | null Prop Type bundles BundleInfo[] Prop Type Description Default Since raw boolean Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk. false 6.14.0 Prop Type toLastSuccessful boolean Prop Type delayConditions DelayCondition[] Prop Type Description kind DelayUntilNext Set up delay conditions in setMultiDelay value string Prop Type Description Since version string Result of getLatest method 4.0.0 checksum string 6 major boolean message string sessionKey string error string old string url string manifest ManifestEntry[] 6.1 Prop Type Description Default Since channel string The channel to get the latest version for The channel must allow 'self_assign' for this to work undefined 6.8.0 Prop Type Description Since status string Current status of set channel 4.7.0 error string message string Prop Type channel string triggerAutoUpdate boolean Prop Type triggerAutoUpdate boolean Prop Type Description Since channel string Current status of get channel 4.8.0 error string message string status string allowSet boolean Prop Type Description Since channels ChannelInfo[] List of available channels 7.5.0 Prop Type Description Since id string The channel ID 7.5.0 name string The channel name 7.5.0 public boolean Whether this is a public channel 7.5.0 allow_self_set boolean Whether devices can self-assign to this channel 7.5.0 Prop Type customId string Prop Type deviceId string Prop Type enabled boolean Prop Type remove () => Promise<void> Prop Type Description Since percent number Current status of download, between 0 and 100. 4.0.0 bundle BundleInfo Prop Type Description Since bundle BundleInfo Current status of download, between 0 and 100. 4.0.0 Prop Type Description Since bundle BundleInfo Current status of download, between 0 and 100. 4.0.0 Prop Type Description Since bundle BundleInfo Emit when a new update is available. 4.0.0 Prop Type Description Since version string Emit when a new major bundle is available. 4.0.0 Prop Type Description Since bundle BundleInfo Emit when a update failed to install. 4.0.0 Prop Type Description Since version string Emit when a download fail. 4.0.0 Prop Type Description Since bundle BundleInfo Emitted when the app is ready to use. 5.2.0 status string Prop Type available boolean Prop Type enabled boolean Prop Type enabled boolean

pending: The bundle is pending to be SET as the next bundle. downloading: The bundle is being downloaded. success: The bundle has been downloaded and is ready to be SET as the next bundle. error: The bundle has failed to download.

'success' | 'error' | 'pending' | 'downloading'

'background' | 'kill' | 'nativeVersion' | 'date'

Listen to download events
  import { CapacitorUpdater } from '@capgo/capacitor-updater';

CapacitorUpdater.addListener('download', (info: any) => {
  console.log('download was fired', info.percent);
});

On iOS, Apple don't allow you to show a message when the app is updated, so you can't show a progress bar.

jamesyoung1337 Thank you so much for your guidance and support, it was impossible to make this plugin work without you.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4