Deeplinks
apm://
is the internal scheme of the SDK APMFor example: a button in a interstitial opening the screen challenges
apm://screen_challenge
You can use these internal scheme from :
- webView inApp (onboarding, walkthrough, campaign)
- button deeplink from a generosity
- button deeplink from a game
- button deeplink from a challenge
apm<PARTNER_ID>
is the external scheme of the SDK APMFor example: a push notification opening the screen challenges
apm0123456789://screen_challenges
For use this external direct deeplink, you must configure the application with this new scheme.
iOS
Android
In file Info.plist, add the scheme apm<PARTNER_ID>, PARTNER_ID is the ID transmitted during the implementation of the project
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- Add this scheme -->
<string>apm<PARTNER_ID></string> <!-- Example : apm0123456789 -->
</array>
</dict>
</array>
Retrieve the deeplink in AppDelegate
-(BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
//Get the deeplink from "url"
}
And, you can execute the deeplink in the HomeViewController of your app
//Check if deeplink is a valid APM deeplink
if([APMWKUtils schemeApmValidForUrl:url.absoluteString]) {
//Launch the deeplink
[APMWebViewUtils handleUrl:[NSURLRequest requestWithURL:deeplink] controller:self];
}
If needed, you can use dispatch_after to launch the deeplink after some delay
//Check if deeplink is a valid APM deeplink
if([APMWKUtils schemeApmValidForUrl:url.absoluteString]) {
//Launch the deeplink after 500ms
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[APMWebViewUtils handleUrl:[NSURLRequest requestWithURL:deeplink] controller:self];
});
}
In file AndroidManifest.xml, add the scheme apm<PARTNER_ID>, PARTNER_ID is the ID transmitted during the implementation of the project
<activity
android:name=".SplashActivity"
<!-- ... -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.APP_BROWSER" />
<!-- Add this scheme -->
<data android:scheme="apm<PARTNER_ID>" /> <!-- Example : apm0123456789 -->
</intent-filter>
</activity>
Retrieve the deeplink in SplashActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
String deepLink = Utils.getDeeplinkFromIntent(getIntent());
}
Class Utils
//Global method for get deeplink
public static String getDeeplinkFromIntent(Intent intent) {
//Deeplink from batch
String deepLink = BatchUtils.deepLinkFromIntent(intent);
//Default deeplink
if(deepLink == null && intent.getData() != null)
deepLink = intent.getData().toString();
return deepLink;
}
//Method util to get deeplink from a push notification from Batch
private static String deepLinkFromIntent(Intent intent) {
String deepLink = null;
if(intent != null && intent.getExtras() != null) {
try {
BatchPushPayload pushData = BatchPushPayload.payloadFromBundle(intent.getExtras());
if(pushData.hasDeeplink())
deepLink = pushData.getDeeplink();
}
catch(Exception e) {
e.printStackTrace();
}
}
return deepLink;
}