Deferred deep linking - optimove-tech/Optimove-SDK-Cordova GitHub Wiki
To enable deferred deep linking add the flag below to your optimove.json
:
{
...
"enableDeferredDeepLinking": true
}
Next, modify config.xml
to add the following:
<widget
...
xmlns:android="http://schemas.android.com/apk/res/android"
>
...
<platform name="android">
<config-file parent="/manifest/application/activity" target="AndroidManifest.xml">
<intent-filter android:label="deepLabel" android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Specify which URIs should be matched. Note, domain should be .lnk.click -->
<data android:scheme="https" android:host="cordova-example-optimove.lnk.click"/>
</intent-filter>
</config-file>
<edit-config file="AndroidManifest.xml" target="/manifest/application/activity/intent-filter/category/[@android:name='android.intent.category.LAUNCHER']/../.." mode="merge">
<activity android:name="OptimoveMainActivity"/>
</edit-config>
</platform>
</widget>
Note that the subdomain you specify above should match the one you specified on the deep link configuration page on the Optimove UI.
Note that setting
android:autoVerify="true"
will verify ownership of the domain, so, instead of offering a list of apps to select from your app will open automatically. No further actions are needed to enable this.
Make sure to run cordova prepare android
to apply changes from config.xml
.
-
config.xml
changes set launcher activity toOptimoveMainActivity
which extendsMainActivity
generated by Cordova.OptimoveMainActivity
has overrides required for Optimove DDL to function. If you are having trouble with this setup you can manually copy the overrides into the activity of your choice.
First, you need to associate a domain with your app. Note that the subdomain you specify here should match the one you specified on the deep link configuration page in the Optimove UI.
Add the Associated Domains
capability to your main app target. Set 'domains' to applinks:{yourSubdomain}.lnk.click
Next, if your generated native project contains AppDelegate (most likely), add the following to the AppDelegate.m
:
#import "Bridging-Header.h"
...
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *restorableObjects))restorationHandler {
return [Optimove_Cordova application:application userActivity:userActivity restorationHandler:restorationHandler];
}
If instead there is a SceneDelegate, add the following to the SceneDelegate.m
:
#import "Bridging-Header.h"
...
- (void) scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity API_AVAILABLE(ios(13.0)){
[Optimove_Cordova scene:scene userActivity:userActivity];
}
- (void)scene:(UIScene * _Nonnull)scene willConnectToSession:(UISceneSession * _Nonnull)session options:(UISceneConnectionOptions * _Nonnull)connectionOptions API_AVAILABLE(ios(13.0)){
[Optimove_Cordova scene:scene session:session options:connectionOptions];
}
Finally, configure a deep link handler:
Optimove.setDeepLinkHandler((deepLink: DeepLink) => {
//
});