Notify users when a new version of your Android app is available, and prompt them with the Play Store link. A port of the iOS library of the same name.

Overview

Android Arsenal Circle CI Release

Siren for Android

Notify users when a new version of your Android app is available, and prompt them with the Play Store link.

This is a port of the iOS library of the same name: https://github.com/ArtSabintsev/Siren

About

Siren checks a user's currently installed version of your Android app against the latest version information stored in a JSON file on a server URL you provide. (Unfortunately, the Google public API for version checking requires a token, and due to logistics and rate limiting, it's not feasible to use the API from an Android app).

If a new version is available, an alert can be presented to the user informing them of the newer version, and giving them the option to update the application. Alternatively, Siren can notify your app programmatically, enabling you to inform the user through alternative means, such as a custom interface.

  • Siren is built to work with semantic version numbering to provide a range of update suggestions for your customers
  • Siren is a Java language port of a Siren, an iOS Swift library that achieves the same functionality
  • Siren is actively maintained by Egghead Games for their cross-platform mobile/tablet apps (great mind puzzles with no ads!)

Features

  • Gradle support (using JitPack)
  • Localized for 20+ languages (See Localization Section)
  • Three types of alerts (see Screenshots & Alert Types)
  • Optional override methods (see Optional Override section)
  • Accompanying sample Android app

Similar Android libraries

Choose what works best for your scenario. We chose not to "screenscrape" the Google Play Listing. We've kept the prompt & update scenarios simple. We kept close to the iOS Siren library to keep our iOS & Android apps similar. Other Android solutions: AppUpdater (the most comprehensive and feature rich library, including support for checks at Amazon and FDroid), Gandalf (also has a "companion" iOS solution), Update Checker, Fit (callback framework, no UI),

Screenshots & Alert Types

  • The left picture forces the user to update the app.
  • The center picture gives the user the option to update the app.
  • The right picture gives the user the option to skip the current update.
  • These options are controlled by the SirenAlertType enum.

Force update Optional update Skip update

Setup

A minimal usage is to add the following to the onCreate of your main activity. This will check at most once a day for a new version and give the user the option to choose "Update" or "Next time".

private static final String SIREN_JSON_URL = "https://example.com/com.mycompany.myapp/version.json";

Siren siren = Siren.getInstance(getApplicationContext());
siren.checkVersion(this, SirenVersionCheckType.DAILY, SIREN_JSON_URL);

Installation Instructions

Add the JitPack.io repository to your root build.gradle:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

Add a dependency to your application related build.gradle

dependencies {
    compile 'com.github.eggheadgames:Siren:1.4.+'
}

Host a Json document with a public access that will describe your application package name and current application version.

{ "com.example.app": { "minVersionName": "1.12.2" } }

OR

{ "com.example.app": { "minVersionCode": 7 } }

Parameters supported on the JSON document:

  • minVersionName: The minimum version name required.
  • minVersionCode: The minimum version code required, minVersionName will take precendence if both specified.
  • enable: A boolean flag to remotely toggle the version check feature.
  • force: A boolean flag to remotely set alertType as FORCE on every type of update.

Example:

{ "com.example.app": { "minVersionCode": 7, "enable": true, "force": false } }

Options

The SirenVersionCheckType controls how often the server is checked for a new version, and hence how often the user will be prompted. You can set it to IMMEDIATELY, DAILY or WEEKLY.

You can also define the dialog appearance and behaviour by setting SirenAlertType to react according to your version increment per Semantic Versioning. The default is SirenAlertType.OPTION. This generates a 2 button "Next Time" or "Update" alert. Other values are FORCE, SKIP and NONE. NONE will not display an alert, but will call your listener with appropriate text to display. See Example below.

You can combine these options to have different behaviour for different version changes. For example, you might will force a user to upgrade for a major version change (e.g. 1.x.x to 2.x.x), give them a "Next time" option for a minor version change (e.g. 1.2.x to 1.3.x) and add a 3rd "Skip this version" option for a 3rd or 4th level change (e.g. 1.2.5 to 1.2.6).

As well as the levels: Major, Minor, Patch and Revision, you can also set messages based on the versionCode of your app by using a minVersionCode field instead of minVersionName.

The following code shows how you can display "stricter" dialogs based on the version severity, with no dialog displayed for a versionCode change:

        Siren siren = Siren.getInstance(getApplicationContext());
        siren.setMajorUpdateAlertType(SirenAlertType.FORCE);
        siren.setMinorUpdateAlertType(SirenAlertType.OPTION);
        siren.setPatchUpdateAlertType(SirenAlertType.SKIP);
        siren.setRevisionUpdateAlertType(SirenAlertType.NONE);
        siren.checkVersion(this, SirenVersionCheckType.IMMEDIATELY, SIREN_JSON_DOCUMENT_URL);

If you'd like to just use versionCode for changes, you could check every time and force an update using code like this:

        Siren siren = Siren.getInstance(getApplicationContext());
        siren.setVersionCodeUpdateAlertType(SirenAlertType.FORCE);
        siren.checkVersion(this, SirenVersionCheckType.IMMEDIATELY, SIREN_JSON_DOCUMENT_URL);

Example

Some developers may want to display a less obtrusive custom interface, like a banner or small icon. You may also wish to control which level of update to force a user to update vs deferring to later.

You can find a fully functional sample project at https://github.com/eggheadgames/SirenSample.

Here is a code sample that shows how to handle all the alerts yourself:

    private void checkCurrentAppVersion() {
        Siren siren = Siren.getInstance(getApplicationContext());
        siren.setSirenListener(sirenListener);
        siren.setMajorUpdateAlertType(SirenAlertType.NONE);
        siren.setMinorUpdateAlertType(SirenAlertType.NONE);
        siren.setPatchUpdateAlertType(SirenAlertType.NONE);
        siren.setRevisionUpdateAlertType(SirenAlertType.NONE);
        siren.setVersionCodeUpdateAlertType(SirenAlertType.NONE);
        siren.checkVersion(this, SirenVersionCheckType.IMMEDIATELY, SIREN_JSON_DOCUMENT_URL);
    }

    ISirenListener sirenListener = new ISirenListener() {
        @Override
        public void onShowUpdateDialog() {
            Log.d(TAG, "onShowUpdateDialog");
        }

        @Override
        public void onLaunchGooglePlay() {
            Log.d(TAG, "onLaunchGooglePlay");
        }

        @Override
        public void onSkipVersion() {
            Log.d(TAG, "onSkipVersion");
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "onCancel");
        }

        @Override
        public void onDetectNewVersionWithoutAlert(String message) {
            Log.d(TAG, "onDetectNewVersionWithoutAlert: " + message);
        }

        @Override
        public void onError(Exception e) {
            Log.d(TAG, "onError");
            e.printStackTrace();
        }
    };

Localization

Siren is localized for Arabic, Armenian, Basque, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, English, Estonian, French, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Latvian, Lithuanian, Malay, Polish, Portuguese (Brazil), Portuguese (Portugal), Russian, Slovenian, Swedish, Spanish, Thai, and Turkish.

You may want the update dialog to always appear in a certain language, ignoring Android's language setting. This is supported with the setLanguageLocalization method. For example, you can force a French update dialog by setting the locale as follows:

    Siren.setLanguageLocalization(SirenSupportedLocales.FR)

Testing Siren

Change the url in your app to point to a test location (e.g. http://myjson.com/ is a convenient test site). Create an appropriate file and run your app with the temporary url.

For example, if my app's current version is 2.1.0.0 and the applicationId is com.eggheadgames.sirensample, I could create a json file with contents:

{"com.eggheadgames.sirensample":{"minVersionName":"2.2.1.1"}}

Then, add code like the following in the onCreate() of my app's home page:

    private Siren siren = Siren.getInstance(getApplicationContext());
    siren.checkVersion(this, SirenVersionCheckType.IMMEDIATELY, "https://api.myjson.com/bins/198mf");

Running this should show an update dialog when I start the app. Of course using a value other than IMMEDIATELY may not bring an immediate prompt, unless your SharedPreferences are being deleted between attempts.

Comments
  • [solved]custom configurations ignored...cant set dialog to

    [solved]custom configurations ignored...cant set dialog to "force"

    I tried multiple ways & even followed the sample to the letter, but I can't set my dialog to "force" so I can finally "force" my users to install the latest updates....it keeps using the default settings...the two button dismiss & update! this is the only library that worked for me & its the simplest...but it just won't let me set my own configurations what so ever

    I also even changed my json file from version name to versioncode just to be sure...but its still the same problem

    question 
    opened by Xstar97 17
  • Dialog Title

    Dialog Title "Update Available"

    Dialog title is only showing on Android 5 device. I have run the code on: Samsung Note 3, Android 5.0.1 (Shows title) Nexus 7, Android 6.0.1 (No title) Samsung S6, Android 7.0.1 (No title)

    How to i ensure that the title is showing on all devices?

    opened by janicelco 7
  • Add additional JSON params for server control of update prompts

    Add additional JSON params for server control of update prompts

    Close #25

    This PR adds two additional parameters on the JSON file

    1. force (Boolean, if true, alertType on all types of version update will be set to FORCE)
    2. enable (Boolean, toggle version check functionality. If disabled, Siren will not do version check)
    opened by saraht129 7
  • Added a way to read local json located in the assets folder with file…

    Added a way to read local json located in the assets folder with file…

    … name in place of a web url.

    Some people might prefer to store the json file locally. I added a check that takes the url input as the file name located in the assets folder, given it's not a web url.

    opened by J6ey 4
  • Chinese language support

    Chinese language support

    There does not seem to be Chinese language support in the library contrary to what the documentation says: https://github.com/eggheadgames/Siren#localization.

    Am I right? Is the support of this language planned?

    opened by pirishd 4
  • just a question about frequency of  .DAILY

    just a question about frequency of .DAILY

    I just want to know exactly how often the .DAILY checks (or WHEN it checks).

    My issue is the following:

    I have the checker set to .IMMEDIATELY right now. I store the version.json file on my github in /docs folder and commit it to the repo when I'm ready to release the update. The problem with this is that it causes people in my app to get the update message before the update is approved by Google Play (takes a few hours).

    SO I thought .DAILY would be better. But, when I had it set to .DAILY, not matter how often I opened the app, it never seemed to notify me that there was an update. (this is why I set it to .IMMEDIATELY).

    So what exactly is the frequency that triggers the .DAILY setting to display the dialog to the users of the app?

    opened by Photogad 3
  • Getting tons of SSL timeout

    Getting tons of SSL timeout

    I've implemented this to my React Native app for a while now but I've just recently added logs on the SirenListener to monitor user conversion. I was surprised by tons of SSL handshake / connection timeout errors.

    I couldn't reproduce the issue on my device, however, and I'm certain that my JSON endpoint has a valid SSL cert. (We have other endpoints on the same server and we've been using it without issue on the RN side).

    It's possible that our CA might not be trusted by the Android system, because this is among the logs: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

    Is there anyway I can load the cert and set a custom SSLSocketFactory? Or is there anything else I should look at?

    opened by saraht129 3
  • Review layout to make sure buttons adapt to their contents, for long translations

    Review layout to make sure buttons adapt to their contents, for long translations

    As texts may be cut in buttons for some languages like French and Russian (see Issue #23), I made sure buttons adapt to their contents by:

    • using a relative layout
    • no longer using fixed heights for buttons, instead using wrap_content for their layout heights
    • getting rid of no longer necessary dimen.xml file
    opened by pirishd 3
  • Add Chinese support

    Add Chinese support

    Add support of Chinese language (closes #19)

    Translations are from https://github.com/ArtSabintsev/Siren/blob/master/Sources/Siren.bundle/zh-Hans.lproj/SirenLocalizable.strings

    opened by pirishd 3
  • SSL handshake issues

    SSL handshake issues

    I've been having some issues on older devices (E.g: KitKat) when the json file is accessed using HTTPS on a server that doesn't support SSL3. The solution is to force HttpsURLConnection's ciphers: http://stackoverflow.com/a/30302235/2124535

    Supported ciphers per platform: https://developer.android.com/reference/javax/net/ssl/SSLSocket.html

    PR sent

    opened by bre7 3
  • request: check and show

    request: check and show "You have the latest" dialog

    its me again...annoying...right? So I was wondering since I am able to check if my app has an update & if there is show an update dialog...but if there isn't an update then a no update dialog pops up saying "you have the latest update....blah blah" it will be cool if this was an extra option... could you also add this in the next update?

    enhancement wontfix 
    opened by Xstar97 3
  • Bug when customizing the Siren standard UI

    Bug when customizing the Siren standard UI

    I'm trying to display a custom UI when the app is out of date instead of the standard dialog provided in this library. I do this by following the README from the "Example"-section. When I follow that exact code (create my own ISirenListener and add my own UI in the onShowUpdateDialog-method) and set all Siren Alert-types to NONE, I get this error:

    I open the app (I have a lower version number hard coded for testing so it will always be called) and my own custom UI is displayed. However, the standard Siren UI is still displayed underneath my own UI. When I close my own UI I can then see the Siren UI. I tried this for a custom dialog and standard snackbar and I get the same result for both.

    I don't understand, if I set the Alert-types to NONE, then why does the standard Siren UI still appear? I only want my own UI to show.

    opened by FelixEder 1
  • Feature: Get app version from Google Play Store rather than hosting a json

    Feature: Get app version from Google Play Store rather than hosting a json

    I really like this library 👍 Very nice work!

    But I realized that it didn't work the same way as the iOS version

    So I added this is the new method:

    public void checkVersion(Activity activity, SirenVersionCheckType versionCheckType) {
    ...
    }
    

    So there is no need to pass the url of the json 🙌

    Note: I added this as an extra functionality, so if you still want to keep the updates alerts via json you can 👍

    opened by robertofrontado 5
  • Added Support for Custom Message

    Added Support for Custom Message

    You can send a custom message from the server side. e.g if the user language is currently not supported by the library, you can send the message from the server.

    opened by ankitguptag18 16
Releases(1.5.2)
Owner
Quality Mobile Puzzle Apps
Quality Mobile Puzzle Apps
A library that checks for your apps' updates on Google Play, GitHub, Amazon, F-Droid or your own server. API 9+ required.

AppUpdater Android Library Android Library that checks for updates on Google Play, GitHub, Amazon, F-Droid or your own server. This library notifies y

Javier Santos 1.9k Jan 2, 2023
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

Leonardo Cardoso 420 Nov 19, 2022
It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

LeoCardz Link Preview for Android It makes a preview from an url, grabbing all the information such as title, relevant texts and images. Visual Exampl

Leonardo Cardoso 420 Nov 19, 2022
Easily notify a user with a simple alert, inform them of an optional update, and in dire situations block the user from accessing older versions of the application completely.

Gandalf In the lifetime of any application there will come a time where you need to drop support for a feature, end of life a product, notify about ma

Bryan Kelly 283 Dec 11, 2022
Android library for finding connected devices on same WiFi network. It can provide IP Address, device name, MAC Address and vendor names.

Android WiFi Tools Android library for finding connected devices on the same WiFi network. It can provide IP Addresses, device names, MAC Address and

Tej Magar 5 Nov 16, 2022
🌄 Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)

React Native Photo Editor (RNPE) ?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and Ph

Baron Ha. 242 Dec 28, 2022
Validator - Notify type based validation for input fields.

Validator - Notify type based validation for input fields.

Mustafa Yiğit 57 Dec 8, 2022
Name UI states, navigate between them, remember where you've been.

Deprecated Flow had a good run and served us well, but new use is strongly discouraged. The app suite at Square that drove its creation is in the proc

Square 2.8k Dec 29, 2022
android-delicious Delicious Android is an Android app which helps you access and save bookmarks via Delicious. It's available over at Google Play.

Delicious Android Delicious Android is an Android app which helps you access and save bookmarks via Delicious. It's available over at Google Play. Fea

Alexander Blom 137 Nov 20, 2022
This app aims at helping people keep track of their job applications, and remind them regularly about the same.

Applications Tracker Lately I have been applying for many roles, and it has become a hard task to keep track of all the applications. Spreadsheets are

Kartik Pant 4 Feb 20, 2022
Android Game App made with kotlin. Allows to play online on the same network!

Reversi - Kotlin/Android Project made for Arquiteturas Móveis at ISEC 2021/2022 Notes Build gradle to run app or install the 'reversi.apk' directly on

André Lopes 1 Feb 5, 2022
Candroid does things different. The Candroid app store is a library of APK client wrappers (F-Droid, APKPure, etc.) For the main Candroid app store, try visiting the Candroid Market.

Candroid App Store Candroid does things different. The Candroid app store is a library of APK client wrappers (F-Droid, APKPure, etc.) For the main Ca

Sean P. Myrick V19.1.7.2 4 Dec 22, 2022
Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.

# Media Recorder Dialog ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.sv

Abdullah Alhazmy 73 Nov 29, 2022
Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.

# Media Recorder Dialog ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.sv

Abdullah Alhazmy 73 Nov 29, 2022
Tidy up your Android status bar before taking screenshots for the Play Store

DEPRECATED This project no longer works on recent versions of Android. Use Android's build-in Demo mode instead. For the curious, more information abo

Emma Vanbrabant 891 Nov 10, 2022
MiHawk 🦅👁️ is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences 💽 to store data.

MiHawk MiHawk ?? ??️ is simple and secure ?? Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack

Nedal Hasan Ibrahem 5 Sep 3, 2022
A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many compose features are not yet available.

Multiplatform Compose A Kotlin library to use Jetpack Compose in Android and iOS. Allow to write UI for both in Kotin. Still experimental as many comp

Clément Beffa 548 Jan 7, 2023
Donations library for Android. Supports Google Play Store, Flattr, PayPal, and Bitcoin

Android Donations Lib Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin. It is used in projects, such as Open

Sufficiently Secure 346 Jan 8, 2023