Version Requirement

  • Sensors Analytics 2.1 and above
  • Android SDK: 4.2.1 and above
  • iOS SDK: 2.1.2 and above
  • Web JS SDK: 1.15.14 and above

When using DeepLink, the following configurations need to be completed:

  • Correctly integrate Android and iOS SDKs in the application
  • Correctly integrate Web JS SDK on activity pages

1. Android

1.1. View the corresponding configuration on the Sensors Analytics page

1.2. Configure AndroidManifest.xml

Put the obtained configuration information into the AndroidManifest.xml file in the Activity that needs to be invoked

1.3. Configure Activity

Override the onNewIntent(Intent intent) method and call setIntent(intent)

@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); }

1.4. Get internal parameters

After successfully launching the application with DeepLink, the setDeepLinkCallback method will be called:

SensorsDataAPI.sharedInstance().setDeepLinkCallback(new SensorsDataDeepLinkCallback() { /** * @description 处理本次 DeepLink 跳转 * @param params 创建渠道链接时填写的参数 * @param success 请求渠道信息是否成功 * @param appAwakePassedTime 本次请求时长 */ @Override public void onReceive(String params, boolean success, long appAwakePassedTime) { } });

2. iOS end

2.1. View the corresponding configuration on the Sensors Analysis page

iOS Project select TARGETS -> Signing & Capabilities -> Associated Domains, turn on the Associated Domains switch and fill in the Domains obtained in the previous stepAssociated Domain configuration:

2.3. Configure URL Scheme

iOS Project select TARGETS -> Info -> For URL Types, click the plus sign (+) to set the URL Schemes that evoke the App. The content is obtained in the previous stepURL Scheme configurationInformation:

After configuring the URL Scheme and Universal Link in the SDK, you can invoke the App through the URL Scheme and Universal Link. Implement the following method in the AppDelegate to listen for DeepLink calls.

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { 	// 业务相关逻辑处理     if ([[SensorsAnalyticsSDK sharedInstance] handleSchemeUrl:url]) {         return YES;     }     return YES; }    - (BOOL)application:(UIApplication*)application continueUserActivity:(NSUserActivity*)userActivity restorationHandler:(void (^)(NSArray*))restorationHandler { 	// 业务相关逻辑处理     if ([[SensorsAnalyticsSDK sharedInstance] handleSchemeUrl:userActivity.webpageURL]) {         return YES;     }     return YES; }    - (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation { 	// 业务相关逻辑处理     if ([[SensorsAnalyticsSDK sharedInstance] handleSchemeUrl:url]) {         return YES;     }     return YES; }

2.5. Obtain in-application parameters

call  - setDeeplinkCallback: method Obtain the in-app parameters entered when creating a channel link. The instructions are as follows:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {       SAConfigOptions *options = [[SAConfigOptions alloc] initWithServerURL:Sa_Default_ServerURL launchOptions:launchOptions];     options.autoTrackEventType = SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd | SensorsAnalyticsEventTypeAppClick | SensorsAnalyticsEventTypeAppViewScreen;     [SensorsAnalyticsSDK startWithConfigOptions:options];  	/// 处理本次 DeepLink 跳转 /// @param params 创建渠道链接时填写的参数 /// @param success 请求渠道信息是否成功 /// @param appAwakePassedTime 本次请求时长          [[SensorsAnalyticsSDK sharedInstance] setDeeplinkCallback:^(NSString * _Nonnull params, BOOL success, NSTimeInterval appAwakePassedTime) {         }];       return YES; }

3. Web end

3.1. Added DeepLink button

Add an Open Now or similar action button to the active page:

3.2. Button event handling

Called at the action of the button openDeepLink() method: If the call times out, it is judged that the call fails, and the browser will jump to the configured download address:

// 初始化深度链接插件 var deeplink = sensors.use('Deeplink',{timeout: 2900}); document.getElementById('theBtn').addEventListener('click', function(e) { e.preventDefault(); deeplink.openDeepLink(); }); 

4. Other

4.1. View Android app signature

Use the keytool -list -v -keystore [path to the keystore] command locally

4.2. View the App ID Prefix of an iOS app

Login to the Apple Developer website and check the corresponding App ID Prefix on the Certificates, Identifiers &amp; Profiles page