Force app update

What’s the best way to ensure people aren’t using outdated versions of an app? I’ve seen some apps like banking apps and even Pokemon Go that force an update at times. I couldn’t find any plugins for that in Ionic Native - does anyone know of anything offhand?

I can’t think of any way you could enforce this in a purely distributed way (IOW, if the user puts the device in airplane mode, nothing you can do).

If the app makes requests to a server in order to function, you could put an app version number into them and return something like 400 app too old for requests from outdated app versions. It would not be bulletproof, because a determined user could defeat it very simply (for example with a proxy), but I suppose it would likely motivate most users to simply upgrade.

That’s actually exactly what I was thinking, thought there might be a more standardized way though. Putting it in airplane mode wouldn’t help them as the app requires a connection to work anyway.

Not sure because I don’t use it, but if you use Ionic Pro Live Deploy, couldn’t this be a way to push your users to always use the last version of your app?

Ok not the last version of the plugin but at least the bundle

Yep, I’ve played around with that and it works great for pure js updates, but binary updates it doesn’t help with. I’ll go with an API call versioning system, it should be work fine.

Have you checked this

Cordova App Update Plugin

For anyone still looking for something like this, you should try this library, It works for both iOS and Android, it checks a file hosted on your server on startup and promps you with an update message.

Mandatory Updates

Hello,

  1. When you add your project in firebase console there is an option of remote config
    !cid_66A96552CF83428EB5E3AFC644BDB3C2%40finouxad
  2. In remote config you can add parameter as per you requirement. For eg you can follow like below

force_update_current_version 1.20.6 (like wise) and if your current version is less you can do the code for the force update…
So its better you add this functionality while uploading your very first build…

  1. Installation:-

ionic cordova plugin add cordova-plugin-firebase-config
npm install @ionic-native/firebase-config
import { FirebaseConfig } from ‘@ionic-native/firebase-config/ngx’;
private firebaseConfig: FirebaseConfig,

  1. Now you can Do the code like below … Like here I restricted my navigation.

forceUpdated() {
this.platform.ready().then(() => {
var myVersion;
this.appVersion.getVersionNumber().then(res => {
myVersion = res
})
this.firebaseConfig.fetch(600).then(res => {
this.firebaseConfig.fetchAndActivate().then(res => {
this.firebaseConfig.getString(‘force_update_current_version’)
.then(async (res: any) => {
if (res > myVersion) {
const alert = await this.alertController.create({
header: ‘New update is Available!!’,
message: 'Please Update to New Version '+ res,
buttons: [
{
text: ‘Update’,
role: ‘Okay’,
cssClass: ‘secondary’,
handler: (blah) => {
this.openNativeSettings.open(“store”);
}
},
]
});

            await alert.present();
          }
          else {
              if (localStorage.getItem('is_show_intro') === 'N') {
                this.navCtrl.navigateRoot('/home');
              } else {
                this.navCtrl.navigateRoot('/introduction');
              }
            }
          }
        })
        .catch((error: any) => {
          console.error('force_update_current_version err1', error)
        });
    })
      .catch(err => {
        console.log('fetchAndActivate err:>>' + err);
      })
  })
    .catch(err => {
      console.log('fetch err:>>' + err);
    })
})

}

Things to remember here is that 1) First call the fetch config function and then get the data… compare it with your app version and then apply your
function accordingly…

Thanks … Hope it helps!

2 Likes

Hey,this is the best option i found to keep my app updated, but im noob with firebase (and with ionic too) so let me ask you. Where do you place the function forceUpdate?

You can call it at the start of your app after the splash screen.
Or you can call this function in home page/ dashboard page of your app.

this will cause you app to suspend

Ok, so, how do you sujest to solve this situation? bc i have 4 days looking for a solution, and im unable to find it. If you have it please post it

I am also looking for the solution… Do let me know if you found something.