Skip to content

Instantly share code, notes, and snippets.

@linkmh
Last active September 26, 2016 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkmh/cd372b92bdbc04c7ac25a3d238d2da95 to your computer and use it in GitHub Desktop.
Save linkmh/cd372b92bdbc04c7ac25a3d238d2da95 to your computer and use it in GitHub Desktop.
Delay Landing Page
// Create a predicate override that stores the args.value to SharedPreferences
void overrideLandingPage() {
Predicate<ActionArguments> landingPagePredicate = new Predicate<ActionArguments>() {
@Override
public boolean apply(ActionArguments arguments) {
switch (arguments.getSituation()) {
case MANUAL_INVOCATION:
return true;
case PUSH_RECEIVED:
return false;
default:
PreferenceManager.getDefaultSharedPreferences(UAirship.getApplicationContext())
.edit()
.putString(LANDING_PAGE_DELAY, arguments.getValue().getString())
.apply();
return false;
}
}
};
UAirship.shared()
.getActionRegistry()
.getEntry(LandingPageAction.DEFAULT_REGISTRY_NAME)
.setPredicate(landingPagePredicate);
}
// Then on the view where you wish to display landing pages
// Display the landing from the URL page previously stored under com.urbanairship.landing_page_for_delay
void showStoredLandingPage() {
String landingPage = PreferenceManager.getDefaultSharedPreferences(UAirship.getApplicationContext())
.getString(LANDING_PAGE_DELAY, null);
if (landingPage != null) {
ActionRunRequest.createRequest(LandingPageAction.DEFAULT_REGISTRY_NAME)
.setSituation(Situation.MANUAL_INVOCATION)
.setValue(landingPage)
.run();
}
}
@emredirican
Copy link

@linkmh Thanks for the snippet. However, I didn't understand where we override the default landing page behaviour. Could you please elaborate on that?

@emredirican
Copy link

@linkmh Nevermind, I think I got that part from the official documentation. Will try and let you know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment