Update Strategies

VH
Last updated last month

Choose you update strategy according your business model

Status Bar (default)

  • PushLink.setCurrentStrategy(StrategyEnum.STATUS_BAR);

  • Title message: "New version of [App Name]".

  • Description message: "Click to Update".

  • Remains on status bar until the installation happens.

  • Clear the message if the admin changes back to an earlier version before the installation.

Friendly Popup (useful for fullscreen apps)

  • PushLink.setCurrentStrategy(StrategyEnum.FRIENDLY_POPUP);

  • Default message: "New version of [App Name]. Do you want to update it?".

  • Default buttons: [Not Now][Update].

  • Remains until the user press [Not Now] or [Update] (Back button is blocked).

  • Default reminder: 3 hours

  • Hide the popup if the admin changes back to an earlier version before the installation.

Don't forget to call PushLink.setCurrentActivity(this); inside onResume

//Only for popups (FRIENDLY_POPUP or ANNOYING_POPUP)
//You MUST do this, otherwise popups will not work.
//Call it in the Activity you want to show the popup.
//You can show the popup in many screens by adding this in more than one Activity.
@Override
protected void onResume() {
super.onResume();
PushLink.setCurrentActivity(this);
}

Annoying Popup (useful for fullscreen when updates can't wait)

  • PushLink.setCurrentStrategy(StrategyEnum.ANNOYING_POPUP);

  • Default message: "For security reasons [App Name] needs to be updated!"

  • Default button: [Update].

  • Very insistent. Remains until the user press [Update] (Dismiss button is blocked).

  • Hide the popup if admin changes back to an earlier version before the installation.

Don't forget to call PushLink.setCurrentActivity(this); inside onResume

//Only for popups (FRIENDLY_POPUP or ANNOYING_POPUP)
//You MUST do this, otherwise popups will not work.
//Call it in the Activity you want to show the popup.
//You can show the popup in many screens by adding this in more than one Activity.
@Override
protected void onResume() {
super.onResume();
PushLink.setCurrentActivity(this);
}

Background

Useful for Kiosk / Point of Sale (POS) applications. There isn't notification. Silent update with no user interaction.

Pushlink covers 100% of this need with two strategies:

  • For Android <= 4 just use NINJA. (it requires a ROOTED device)

  • For Android >= 5 just use CUSTOM. (it requires ADMIN PRIVILEGES on device)

Do you want to perform background updates only when your app is idle? Check the PushLink.idle(boolean) in the jar Javadoc​.

NINJA (Only for rooted devices)

  • PushLink.setCurrentStrategy(StrategyEnum.NINJA);

  • The application is just re-launched in a new version.

NINJA Disclaimer

NINJA worked flawlessly until android 4. 🀘

When android 5 was released NINJA began to have issues and we was forced to implement a <receiver android:name="com.pushlink.android.NinjaReceiver" /> to make it work. Unfortunately it was not fixed completely and it still can fails sometimes, depending the combination of OS version x Vendor. πŸ˜•

So if you have Android >= 5, the better choice is CUSTOM with admin privileges on device.

CUSTOM (Take full control of your installation)

  • PushLink.setCurrentStrategy(StrategyEnum.CUSTOM);

  • When using CUSTOM strategy, pushlink doesn't display anything and will broadcast two actions

  • [your.package.name].pushlink.APPLY is sent EVERY 30 seconds (more or less) when there is a downloaded but not applied new apk. The user have to handle those multiples broadcasts.

  • [your.package.name].pushlink.GIVEUP is sent ONCE when the user gives up the update (in the web admin) before it has been applied.

  • Learn how to silently install. (it requires ADMIN PRIVILEGES)

  • You also can use CUSTOM without admin privileges if you don't want to perform background updates. Sometimes the developer wants to build a fancier notification or execute extra steps.

Sample:

registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Uri apkUri = (Uri) intent.getExtras().get("uri");
//enjoy the apk uri
//notice this will be called every 30s (more or less). You need to handle this.
}
}, new IntentFilter(getPackageName() + ".pushlink.APPLY"));

Customization

You can customize the built in strategies like this:

//Changing default notification messages
StatusBarStrategy sbs = (StatusBarStrategy) PushLink.getCurrentStrategy();
sbs.setStatusBarTitle("Hello, there is a new version");
sbs.setStatusBarDescription("Click to be happy");
​
//Changing strategy
PushLink.setCurrentStrategy(StrategyEnum.FRIENDLY_POPUP);
​
//Modifying new strategy
FriendlyPopUpStrategy fps = (FriendlyPopUpStrategy) PushLink.getCurrentStrategy();
fps.setPopUpMessage("New version available");
fps.setNotNowButton("No, thanks!");
fps.setUpdateButton("Ok, lets go");
fps.setReminderTimeInSeconds(60 * 60); //one hour
​
//You can do the same with AnnoyingPopUpStrategy.class

​