Last active
September 26, 2016 08:54
-
-
Save linkmh/cd372b92bdbc04c7ac25a3d238d2da95 to your computer and use it in GitHub Desktop.
Delay Landing Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
} |
@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
@linkmh Thanks for the snippet. However, I didn't understand where we override the default landing page behaviour. Could you please elaborate on that?