Download app update form url and install it

Overview

capacitor-updater

Download app update from url and install it.

And reload the view.

You can list the version and manage it with the command below.

Install

npm install capacitor-updater
npx cap sync
  import { CapacitorUpdater } from 'capacitor-updater'
  import { SplashScreen } from '@capacitor/splash-screen'
  import { App } from '@capacitor/app'

  let version = ""
  App.addListener('appStateChange', async(state) => {
      if (state.isActive) {
        // Do the download during user active app time to prevent failed download
        version = await CapacitorUpdater.download({
        url: 'https://github.com/Forgr-ee/Mimesis/releases/download/0.0.1/dist.zip',
        })
      }
      if (!state.isActive && version !== "") {
        // Do the switch when user leave app
        SplashScreen.show()
        try {
          await CapacitorUpdater.set(version)
        } catch () {
          SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
        }
      }
  })

  // or do it when click on button
  const updateNow = async () => {
    const version = await CapacitorUpdater.download({
      url: 'https://github.com/Forgr-ee/Mimesis/releases/download/0.0.1/dist.zip',
    })
    // show the splashscreen to let the update happen
    SplashScreen.show()
    await CapacitorUpdater.set(version)
    SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
  }

Be extra carufull for your update if you send a broken update, the app will crash until the user uninstall it.

API

download(...)

download(options: { url: string; }) => Promise<{ version: string; }>

download new version from url, it should be a zip file, with files inside or with a unique folder inside with all your files

Param Type
options { url: string; }

Returns: Promise<{ version: string; }>


set(...)

set(options: { version: string; }) => Promise<void>

set version as current version, set will return error if there are no index.html file inside the version folder

Param Type
options { version: string; }

delete(...)

delete(options: { version: string; }) => Promise<void>

delete version in storage

Param Type
options { version: string; }

list()

list() => Promise<{ versions: string[]; }>

get all avaible versions

Returns: Promise<{ versions: string[]; }>


reset()

reset() => Promise<void>

set the original version (the one sent to Apple store / Google play store ) as current version


current()

current() => Promise<{ current: string; }>

get the curent version, if none are set it return 'default'

Returns: Promise<{ current: string; }>


Inspiraton

Contributer

jamesyoung1337 Thanks a lot for your guidance and support, it was impossible to make this plugin work without you.

Comments
  • Install UX

    Install UX

    Love the effort here, will be watching closely.

    One thing I'd like to point out if it's not been considered already is the install method. It would be great to be able to configure how the app is updated;

    a) Immediate install/switch/restart when the download of the new update is finished b) Manual through function so developer can choose the best time when they know the user isn't doing something important. c) Install/restart/switch when the app re-gains focus (e.g with App.addListener('appStateChange')

    If you wait until re-focus then it prevents the user being in the middle of something when you randomly restart the app. (doesn't handle the case of them switching apps temporarily to copy/paste or reference something else during a form filling exercise of course).

    Apple won't allow you to show an install update prompt so you have to consider the different background approaches.

    Will you be exposing events for download started/finished/failed/update available etc?

    opened by alexcroox 17
  • Add a method for waiting an amount of time before install the update when app is in background

    Add a method for waiting an amount of time before install the update when app is in background

    Hi, I currently use the self-hosted autoupdate method. I tested the behaviour of using cancelDelay() and delayUpdate() but both refer only to the next time app goes in background... It could be useful if we could choose an amount of time before the app installs the update. The main reason is that possibly the user is typing any information in a form, and puts the app in background for searching missing fields (like cvc, iban etc..), but in this particular scenario, if there is a pending update, he will lose all previously typed information.

    Thanks!

    opened by luca-sharryland 13
  • Feature Multi Delay

    Feature Multi Delay

    this close issue #100 changes:

    • update android dependencies (jcenter() deprecated)
    • fix some conditions
    • deprecate setDelay, internally calls setMultiDelay
    • implement delay value for kind "background"

    Now when a delay condition is met the app calls installNext function and reloads. I've tested all delay values, in particular kill and background. I've found only two little problems: 1 - in kill conditions only in ios, cause the app reloads and correctly installs new bundle but my js code (angular app ngOnInit) seems to be the old bundle one. After a second kill, it executes new bundle code. I'm not a swift expert, so if you could debug this I will appreciate it. 2 - in android I've added a listener for appReloaded event to call notifyAppReady (I think is related to problem 1, so code in ngOnInit not reexecuted)

    Tell me if something seems wrong to you Thanks!

    opened by luca-sharryland 12
  • iOS update occasionally fails to copy some files.

    iOS update occasionally fails to copy some files.

    We've had a few reports from users after an update that the app is broken. Based on screenshots we've been sent, in some cases it looks like the css files are missing and other cases some image assets are missing.

    Reloading the app doesn't solve the issue but, if they uninstall the app, download again from the App Store and then reinstall the web app update, it works.

    This points to it not being a device or configuration issue. Perhaps a corrupt download? A nice feature would be to be able to provide a checksum to CapacitorUpdater.download().

    opened by playaz87 9
  • Need download/update progress

    Need download/update progress

    Hi, thank u for awesome project

    I know Just package has asyncProgressHandler for HTTP requests. Maybe that can provide progress event for us.

    resim https://justhttp.github.io/

    I thought there might be people like me who want to show the current progress as a percentage to users.

    Best regards

    opened by OFK0 8
  • Help needed

    Help needed

    Hello ! Since recent ionic crazy pricing trying to find solution :)

    I am new to capacitor only cordova used in the past .

    testing on iOS

    async update() { const update = await CapacitorUpdater.updateApp({ url: 'https://myftpurl/upate.zip', }); console.log(update); }

    gives me{done: false}

    (upate.zip is my www zipped)

    opened by ThodorisElissaios 8
  • WIP: Initial attempt at supporting notifyAppReady() for all update modes

    WIP: Initial attempt at supporting notifyAppReady() for all update modes

    DO NOT MERGE YET!

    This is just an initial attempt, for discussion and deciding how best to proceed. Please forgive me I went a bit overboard.

    1. Encapsulate version details saved in preverences via the 'version' code as key to look up all values. This way they are more easily written/maintained. Essentially a light API over the version, name, status, and I also added a timestamp the zip bundle download occurred on.

    2. Add the concept of a version status (pending, success, or error) All downloaded bundles start as 'pending', then change to success when notifyAppReady() is called, or 'error' if it is NOT called.

    3. Clean up old NativeVersionNative/LatestVersionAutoUpdate/LatestVersionNameAutoUpdate code as it is no longer needed since this does the same thing / is redundant.

    4. Fix download/unzip to bubble exception to client.

    5. Clean up all log statements and e.printStackTrace() to use the TAG and print exception via Android logger.

    6. I am about to remove the duplicate constructor is is not needed and can be fixed with a this(plugin) call.

    opened by lincolnthree 5
  • Unable to capacitor sync on iOS

    Unable to capacitor sync on iOS

    Hello when I tried to run cap sync I get this error. It only happens when this package installed. Is there anyone that have any idea?

    ✖ Updating iOS native dependencies with pod install - failed!
    ✖ update ios - failed!
    [error] Ignoring ffi-1.15.0 because its extensions are not built. Try: gem pristine ffi --version 1.15.0
            Analyzing dependencies
            objc[25636]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib
            (0x1efa1f130) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
            (0x1065202c8). One of the two will be used. Which one is undefined.
            objc[25636]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1efa1f180) and
            /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x106520318).
            One of the two will be used. Which one is undefined.
    
    opened by berkayyildiz 5
  • No clear error message when download fails

    No clear error message when download fails

    When zip download fails for some reason, the plugin just outputs the error "Download failed" Without any clear message / error on what went wrong or why download has failed. Not helpful for debugging / investigating the issue

    opened by snimavat 5
  • Property 'addListener' does not exist on type 'CapacitorUpdaterPlugin'

    Property 'addListener' does not exist on type 'CapacitorUpdaterPlugin'

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

    Property 'addListener' does not exist on type 'CapacitorUpdaterPlugin'

    opened by Kaizodo 5
  • Licencing?

    Licencing?

    Hi,

    This looks like a fantastic library, but the AGPL licence seems a little prescriptive, correct me if I'm wrong, but If I include your npm package I would need to open source the rest of my Ionic mobile application?

    Thanks

    Neil

    opened by broomfn 5
  • App does not auto update

    App does not auto update

    Hi there. I followed all the instructions given here but my app does not auto-update when I open the app a second time after the update is supposed to have auto-install.

    • I build the app (web and android) and uploaded it to Capgo with version 1.0.5
    • I installed the android build in my emulator and open to see it is working.
    • Then I updated the version in package.json to 1.0.6 and then rebuild the app (web build)
    • I upload the new build to Capgo
    • I open my android app for auto-update.
    • I close the app and re-open it, but no update shows.

    Here is my configuration:

    "dependencies": {
        "@capgo/capacitor-updater": "^4.14.17",
    }
    

    src/index.js

    import { CapacitorUpdater } from "@capgo/capacitor-updater";
    CapacitorUpdater.notifyAppReady();
    

    capacitor.config.ts

    plugins: {
        CapacitorUpdater: {
          autoUpdate: true,
        },
     },
    

    Your help is much appreciated. Thank you.

    opened by Zeusmist 16
  • [Android] 404 on self hosted server

    [Android] 404 on self hosted server

    Hello! If for some strange reason (error on CI/CD), the bundled zip in selfhosted server is missing, you can get a 404 response. If capacitorupdate do a request to that address and get a HTTP 404, app will be crash! You should trap exception and do a rollback of the latest version available on device.

    Cheers

    opened by Kaizer69 3
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Awaiting Schedule

    These updates are awaiting their schedule. Click on a checkbox to get an update now.

    • [ ] fix(deps): update dependency com.google.code.gson:gson to v2.10.1
    • [ ] chore(deps): update pnpm to v7.22.0
    • [ ] chore(deps): lock file maintenance

    Detected dependencies

    cocoapods
    ios/Podfile
    github-actions
    .github/workflows/build.yml
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • actions/setup-java v3
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • JS-DevTools/npm-publish v1
    • JS-DevTools/npm-publish v1
    .github/workflows/bump_version.yml
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    .github/workflows/test.yml
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • actions/setup-java v3
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    • actions/checkout v3
    • pnpm/action-setup v2
    • actions/setup-node v3
    gradle
    android/gradle.properties
    android/settings.gradle
    android/build.gradle
    • com.android.tools.build:gradle 7.3.1
    • com.android.volley:volley 1.2.1
    • io.github.g00fy2:versioncompare 1.5.0
    • com.google.code.gson:gson 2.10
    gradle-wrapper
    android/gradle/wrapper/gradle-wrapper.properties
    • gradle 7.6
    npm
    example/package.json
    • typescript ^4.3.2
    • vite ^4.0.0
    package.json
    • @capacitor/android ^4.5.0
    • @capacitor/cli ^4.5.0
    • @capacitor/core ^4.5.0
    • @capacitor/docgen ^0.2.0
    • @capacitor/ios ^4.5.0
    • @ionic/eslint-config ^0.3.0
    • @ionic/prettier-config ^2.0.0
    • @ionic/swiftlint-config ^1.1.2
    • @types/node ^18.11.9
    • @typescript-eslint/eslint-plugin ^5.44.0
    • @typescript-eslint/parser ^5.44.0
    • eslint ^8.28.0
    • eslint-plugin-import ^2.26.0
    • prettier ^2.8.0
    • prettier-plugin-java ^2.0.0
    • rimraf ^3.0.2
    • rollup ^3.4.0
    • swiftlint ^1.0.1
    • typescript ^4.9.3
    • @capacitor/core ^4.0.0
    • pnpm 7.21.0

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • Make download happen even the app is kill with background task

    Make download happen even the app is kill with background task

    exemple of how to do it: https://github.com/EkoLabs/react-native-background-downloader (ios/ android) https://github.com/thibaultCha/TCBlobDownloadSwift (ios)

    opened by riderx 0
  • Download the OTA update as individual files

    Download the OTA update as individual files

    Would help if the OTA updates could be downloaded as individual files rather than one big .zip file. Especially helpful with app having a bigger OTA update size and users downloading the OTA on Mobile Data.

    opened by colenso 4
Owner
Martin DONADIEU
🧞‍♂️INDIE MAKER | 🎙Podcaster | 🏄‍♀️ Life Goal : Help 20% of the world become 20% happier
Martin DONADIEU
AIB indicates for your app users which audio is playing. Just like the Podcasts app.

Audio Indicator Bars for iOS and tvOS Indicates for your app users which audio is playing. Just like the Podcasts app. Index Requirements and Details

Leonardo Cardoso 285 Nov 23, 2022
Voice Memos is an audio recorder App for iPhone and iPad that covers some of the new technologies and APIs introduced in iOS 8 written in Swift.

VoiceMemos Voice Memos is a voice recorder App for iPhone and iPad that covers some of the new technologies and APIs introduced in iOS 8 written in Sw

Zhouqi Mo 322 Aug 4, 2022
Nobetci Eczacim is open-source App Store Application which users can get pharmacy information and location easily and safely.

Pharmacy-On-Duty Nobetci Eczacim Project Description This project designed for make it easier for people to search for a pharmacy on duty. App Store A

Mert Demirtas 5 Sep 19, 2022
Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern and MVVM architecture.

Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern ?? and MVVM architecture ?? . Made with love ❤️ by Sameer Nawaz

Sameer Nawaz 120 Jan 4, 2023
Swift Radio is an open source radio station app with robust and professional features.

Swift Radio Swift Radio is an open source radio station app with robust and professional features. This is a fully realized Radio App built entirely i

Ahmed AlOtaibi 0 Oct 13, 2021
macOS app that allows the control of Spotify and AppleMusic/iTunes music playback from the menu bar.

PlayStatus is a simple macOS app that allows the control of Spotify, Apple Music(macOS 10.15+) and iTunes including iTunes Radio/Beats1 playback from

Nikhil Bolar 114 Dec 28, 2022
SoundManager - A simple framework to load and play sounds in your app.

SoundManager - A simple framework to load and play sounds in your app.

Jonathan Chacón 3 Jan 5, 2022
App for adding and listening audio files

SomeSa SomeSa (самса) – приложение, позволяющее загружать и воспроизводить произвольные аудиофайлы. Протестировано на форматах файлов .wav и .mp3, раз

Yegor Dobrodeyev 0 Nov 7, 2021
App for searching music and films in iTunes

inMovies App description: This is an app for searching contnent such as films and music in iTunes. Running the app brings you to page with following c

Egor 0 Nov 7, 2021
The easiest way to prepare, play, and remove sounds in your Swift app!

Chirp The easiest way to prepare, play, and remove sounds in your Swift app! ##Installation ###CocoaPods Installation Chirp is available on CocoaPods.

null 309 Dec 17, 2022
This app demonstrates how to use the Google Cloud Speech API and Apple on-device Speech library to recognize speech in live recorded audio.

SpeechRecognitionIOS This app demonstrates how to use Google Cloud Speech API and Apple on-device Speech library to recognize speech in live audio rec

Josh Uvi 0 Mar 11, 2022
SleepingBaby - Track your kids activity and allow them sleep soundly with relaxing music in ONE app

Sleeping Baby Скачать в AppStore. Ключевые используемые технологии: UIKit, MVVM,

Egor Kostyukhin 0 Jan 7, 2022
MusicPlayer - Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern and MVVM architecture

Skailer ?? Beautiful Music Player app built using SwiftUI to demonstrate Neumorp

null 23 Dec 10, 2022
11t is an iOS and Android app for connecting to Mastodon, written in Flutter.

README 11t is an iOS and Android app for connecting to Mastodon, written in Flutter. I connect to Mastodon on mastodon.social, but everyone can start

Jeroen Smeets 88 Dec 23, 2022
AudioKit 67 Dec 21, 2022
An app to get you the latest and the trending news based on your location.

Newsline Link to APK : http://bit.ly/newslineapp Newsline is an android application made with flutter which makes use of NewsAPI.org to fetch and serv

Ayush Shekhar 19 Nov 11, 2022
Proof of concept app for trying to integrate passkeys and WebAuthn into Vapor

Vapor Passkey Demo Proof of concept app for trying to integrate passkeys and WebAuthn into Vapor Usage Clone the project, then in Terminal run swift r

Tim Condon 70 Dec 20, 2022
A small app which fetches and renders jokes from The Internet Chuck Norris Database

This small iOS app fetches and renders jokes from the Chuck Norris Internet Database API.

Chris Williamson 0 Jun 6, 2022
FDWaveformView is an easy way to display an audio waveform in your app

FDWaveformView is an easy way to display an audio waveform in your app. It is a nice visualization to show a playing audio file or to select a position in a file.

William Entriken 1.1k Dec 21, 2022