Latest 1.0.7
Homepage https://github.com/andoma93/FirebaseCheckVersion
License MIT
Platforms ios 9.0
Dependencies Firebase/RemoteConfig
Authors

Version
License
Platform

Summary

FirebaseCheckVersion is a simple iOS Library that notifies users when a new version of your app is available. It’s configurable through Firebase Remote Configuration. Please read the Configuration section to know more.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

An iOS Swift project and 10 minutes of your time.

Installation

FirebaseCheckVersion is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'FirebaseCheckVersion'

Configuration

First of all you need, if you haven’t yet, to create a Firebase Project for your iOS Application.
Go to Firebase Console and create your project:

alt text

Once you created your project you need to link your iOS Application:

alt text

Now fill the bundle id with yours, download the GoogleService-Info.plist that Firebase created for your project and drag it into your xCode Project in this way:

alt text

Go now in your AppDelegate.swift file and write FirebaseApp.configure() how first line of your didFinishLaunchingWithOptions: method in this way:

import Firebase
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    // Override point for customization after application launch.
    return true
}

Done!

Usage

Add versions to your Firebase

Once you configured all, you need to set the version on your Firebase Project, so navigate to "Remote Config" section into Firebase and add a new property which key is iOSVersion_<yourVersionWithUnderscore> where is your version number with underscore instead of points:
Eg.

1.0 --> 1_0
1.1 --> 1_1
10.03.9 --> 10_03_9

So if your app version is 1.0 simple configure a new Remote Configuration like this:

alt text

The possible values you can give to your version are:

  1. versionOk which means the version is up to date
  2. infoUpdate which means the version is not the last avaiable, but can be used for your application
  3. forceUpdate which means the version is not the last avaiable and can NOT be used for your application

Add check to your application

Silent Check

In the UIViewController you want to add the check silently you need to insert these code lines:

import CheckVersion
...

CheckVersion.check{ result in
    //check result and do what you want
}

where result is a enum with these possible values:

  1. versionOk which means your version is currently ok
  2. infoUpdate which means the version is not the last avaiable, but can be used for your application
  3. forceUpdate which means the version is not the last avaiable and can NOT be used for your application
  4. versionUnknown which means your version is not configured on Firebase Console
  5. error which means an error occurred

Alert Check

In the UIViewController you want to add the check with Alert you need to insert these code lines:

import CheckVersion
...

CheckVersion.checkWithAlert(viewController: self){ result in
    //check result and do what you want
}

where result is a Bool with value true if your version is ok, false otherwise.

drawing drawing drawing

Application Configuration

Is possible to choose some custom library configuration like these:

import CheckVersion
...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    CheckVersionConfiguration.default.urlStore = URL(string: "itms-apps://itunes.apple.com/<myAppId>")! //where myAppID is your store application id
    CheckVersionConfiguration.default.continueOnError = false //continue in case of error (default is true)
    CheckVersionConfiguration.default.continueOnVersionUnknown = false //continue in case of version unknown (default is true)
    CheckVersionConfiguration.default.prependKey = "" //the prepend string you can insert in firebase console before (default is 'iOSVersion_')
    CheckVersionConfiguration.default.duration = TimeInterval(120) //the duration of Firebase Remote Configuration Cache (default is 60 seconds)
    // Override point for customization after application launch.
    return true
}

Right now the library is localized just in English, so if you want to use built-in alerts is possible to change these configurations property too:

import CheckVersion
...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    CheckVersionConfiguration.default.labelAlertError = "Si è verificato un errore generico, per favore riprova più tardi"
    CheckVersionConfiguration.default.labelButtonNotNow = "Non adesso"
    CheckVersionConfiguration.default.labelButtonUpdate = "Aggiorna"
    CheckVersionConfiguration.default.labelForceUpdate = "E' disponibile una nuova versione dell'app: per favore aggiornala adesso"
    CheckVersionConfiguration.default.labelInfoUpdate = "E' disponibile una nuova versione dell'app: se vuoi aggiornala adesso"
    CheckVersionConfiguration.default.labelAlertTitle = "Attenzione"
    CheckVersionConfiguration.default.labelButtonOk = "Ok"
    // Override point for customization after application launch.
    return true
}

Author

Mario Monaco, [email protected]

License

FirebaseCheckVersion is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "FirebaseCheckVersion",
    "version": "1.0.7",
    "summary": "Notify users about updates of your application",
    "swift_version": "4.1.2",
    "description": "A simple Library that notifies users when a new version of your app is available through Firebase Remote Configuration",
    "homepage": "https://github.com/andoma93/FirebaseCheckVersion",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "andoma93": "[email protected]"
    },
    "source": {
        "git": "https://github.com/andoma93/FirebaseCheckVersion.git",
        "tag": "1.0.7"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "CheckVersion/Classes/**/*",
    "dependencies": {
        "Firebase/RemoteConfig": []
    },
    "static_framework": true
}

Pin It on Pinterest

Share This