Netmera Developer Guide
Netmera Docs
  • Netmera Developer Guide
  • Platforms
    • iOS
      • New iOS (Swift)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Widget and In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Advertising ID
        • Changelog
      • Former iOS (Objective-C)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Push Payload Receivers
          • Widget and In-App Messages
          • Customizing In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
          • Custom Web View Presentation
          • Push Icon
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Data Transfer
        • Advertising ID
        • SSL Pinning
        • Changelog
    • Android
      • SDK Integration
        • Huawei Integration
        • Huawei Message Receipt
        • Android Integration FAQs
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
        • Custom Web View Presentation
        • Push Icon
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
        • Background Location Permission
      • User & Attributes
      • Data Transfer
      • Advertising ID
      • App Tracking
      • SSL Pinning
      • Changelog
    • Web
      • SDK Setup
        • Self-Hosted SDK Setup
      • Mobile Web Push for iOS
      • Deep Linking
        • Custom Deep Links
      • Events
      • User & Attributes
    • React Native
      • SDK Integration
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • Changelog
    • Flutter
      • SDK Integration
      • Push Notifications
        • Push Notification Permissions
        • Widget and In-App Messages
        • Flutter iOS Media Push
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • SSL Pinning
      • Changelog
    • Cordova
      • SDK Integration
      • Push Notifications
      • Sound & Vibration
      • Push Inbox
      • Events
      • User & Attributes
    • Unity
      • SDK Integration
      • Sound & Vibration
      • Events
      • User & Attributes
      • Changelog
  • Integrated Modules
    • Optimove
    • Adjust
    • Mixpanel
    • IYS Integration
    • VIA Integration
      • Short URL Consent Requests
      • OTP Consent Requests
        • OTP Confirmation Completion
      • VIA Email Rejection Link Generation
      • ETK Rejection via SMS
  • API Documentation
    • REST API
      • Setup
      • Notifications
      • Events
      • User & Device Management
      • Inbox Feature
      • GDPR
      • Error Responses
  • FAQs
    • Push Notifications FAQs
Powered by GitBook
On this page
  • Deep Links
  • Universal Links
  • Deeplink Callbacks
  • Custom Intent Handling

Was this helpful?

  1. Platforms
  2. Android

Deep Linking

Deep Links

Step 1: Add Intent Filters to Your Manifest

Add intent filters to your app's manifest file to define the URLs or URIs your app can handle. This configuration allows both example://gizmos and http://www.example.com/gizmos to open the same activity in your app.

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos">
    
    <!-- Intent filter for handling HTTP URLs that begin with "http://www.example.com/gizmos" -->
    <intent-filter android:label="@string/filter_view_http_gizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "http://www.example.com/gizmos" -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- Note: The leading "/" is required for pathPrefix -->
    </intent-filter>
    
    <!-- Intent filter for handling "example://gizmos" URIs -->
    <intent-filter android:label="@string/filter_view_example_gizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "example://gizmos" -->
        <data android:scheme="example"
              android:host="gizmos" />
    </intent-filter>
    
</activity>

Step 2: Avoid Merging Data Elements in Intent Filters

When defining multiple data elements in the same intent filter, Android merges their attributes, which can lead to unintended behavior. For example:

<!-- Custom in-app message style -->
<intent-filter>
  ...
  <data android:scheme="https" android:host="www.example.com" />
  <data android:scheme="app" android:host="open.my.app" />
</intent-filter>

This configuration will match:

  • https://www.example.com

  • app://open.my.app

  • app://www.example.com

  • https://open.my.app

To avoid this, use separate intent filters for unique URL schemes and hosts.

Step 3: Enable Netmera SDK for Deep Link Handling

To allow the Netmera SDK to handle deep links automatically, add the following configuration to your build.gradle (app) file:

android {
  ...
  defaultConfig {
    ...
    // The following line is for automatic deep link handling.
    // If you don't want Netmera to handle deep links, set this value to false.
    resValue "bool", "netmera_use_default_deeplink_action", "true"
    ...
  }
}

Step 4: Retrieve Deep Link URI in Your App

To access the deep link URI programmatically, use the NMPushActionCallbacks class provided by the Netmera SDK:

public class NGPushActionCallbacks implements NMPushActionCallbacks {

  @Override
  protected void onPushOpen(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
    Uri deeplinkUri = netmeraPushObject.getDeepLink();
  }
}

For more detailed information on deep linking in Android, you can refer to the official Android documentation:

Android Deep Linking Documentation

Universal Links

Step 1: Configure the Project

Set android:autoVerify="true" in one of the web URL intent filters in your app manifest. This enables Android to verify the link association with your website.

<!-- Custom in-app message style -->
<activity ...>
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="www.naturalworld.com" />
        <data android:scheme="https" />
    </intent-filter>
</activity>

Step 2: Configure the Website

  1. Create an assetlinks.json file with the following details:

  • package_name: The application ID declared in your app's build.gradle file.

  • sha256_cert_fingerprints: The SHA256 fingerprints of your app’s signing certificate.

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.netmera.naturalworld",
    "sha256_cert_fingerprints": [
      "XX…XX"
    ]
  }
}]
  1. Host the assetlinks.json file and publish the assetlinks.json file on the domain. Ensure it is hosted on the website to indicate the association of Android apps with the website and to verify the app's URL intents.

Deeplink Callbacks

You can retrieve the universal link URL from the NMPushActionCallbacks class:

public class NGPushActionCallbacks implements NMPushActionCallbacks {

  @Override
  protected void onPushOpen(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {

    Uri universalLinkUrl = netmeraPushObject.getDeepLink();
  }
}

Custom Intent Handling

Step 1: Configure Deeplink in Push Action

  • In the Netmera panel or via REST API, set deeplink as the push action.

  • Include any custom parameters in the deeplink configuration.

Step 2: Implement a Custom Callback in the Android SDK

  • Define a custom handler in the SDK's initialization configuration by assigning it to the nmDeeplinkCallback.

  • This setup directs the SDK to bypass its default handling of the deeplink and forward the pushObject to your custom callback.

PreviousPush IconNextCustom Deep Links

Last updated 3 months ago

Was this helpful?

For more detailed information on deep linking in Android, you can refer to the official documentation.

Android Deep Linking