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
        • Live Activities
        • 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
        • Custom FCM and HMS Implementations
        • 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
        • Custom FCM and HMS Implementations
      • 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 Linking
  • Scheme and Host Properties
  • Deep Link Callback
  • Universal Links
  • Handle Universal Links in the App

Was this helpful?

  1. Platforms
  2. iOS
  3. Former iOS (Objective-C)

Deep Linking

Deep Linking

To redirect users to a specific page or view in your app via push notifications with custom action buttons, you can use deep links. Follow these steps to set up deep linking in your app:

  1. Set Up a URL Scheme In your Xcode project, define a custom URL scheme (netmera://).

  2. Configure Info.plist

    • Open your Info.plist file.

    • Add a new key: URL types. Xcode will create an array with a dictionary called Item 0.

    • Inside Item 0, add:

      • URL identifier > Set it to your custom scheme.

      • URL Schemes >This creates an array.

      • Item 0 inside URL Schemes > Set it to your custom scheme.

  3. Handle the Deep Link Add this method to your app delegate:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
{
    //handle URL here to navigate to custom views

    return true
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation
{
    //handle URL here to navigate to custom views

    return YES;
}

Scheme and Host Properties

You can use the scheme and host of a URL to navigate to different screens in your app.

For example, if you have deep links like netmera://screenOne and netmera://screenTwo, the scheme is netmera, and the host tells you which screen to show (screenOne or screenTwo).

Here’s how you can use it in code:

if url.scheme == "netmera" {
    if url.host == "screenOne" {
        // Present view controller for screenOne
    } else if url.host == "screenTwo" {
        // Present view controller for screenTwo
    }

    // Or you can use the host property directly
}

Deep Link Callback

Netmera SDK triggers openURL when users tap a notification. To ensure deep linking works properly, implement Netmera Delegate:

// Extends NetmeraPushDelegate

// In didFinishLaunchingWithOptions, after calling Netmera.start()
Netmera.setPushDelegate(self)
func shouldHandleOpen(_ url: URL!, for object: NetmeraPushObject!) -> Bool {
    // Deeplink is checked (valid or invalid)
    return true
}

func handleOpen(_ url: URL!, for object: NetmeraPushObject!) {
    // Control and redirect method
    print("handleOpenUrl: \(url), for pushObject: \(object)")
}
// Extends NetmeraPushDelegate

// In didFinishLaunchingWithOptions
[Netmera setPushDelegate:self];
- (BOOL)shouldHandleOpenURL:(NSURL *)url forPushObject:(NetmeraPushObject *)object {
    // Deeplink is checked (valid or invalid)
    return YES;
}

- (void)handleOpenURL:(NSURL *)url forPushObject:(NetmeraPushObject *)object {
    // Control and redirect method
    NSLog(@"handleOpenURL: %@ forPushObject %@", url, object);
}

Universal Links

  1. Configure the Project

  • Add "Associated Domains" capability.

  • In the domain section, add entries like applinks:www.mywebsite.com.

  1. Configure the Website

Create an apple-app-site-association file:

  • Host this file on your HTTPS server at / or /.well-known/.

  • The appID consists of the Team ID (found in Apple Developer Account) and the App Bundle ID (found in the project).

  • Specify the paths the app supports (e.g., /products).

{
    "applinks": {
        "apps": [],
        "details": [{
            "appID": "4321.com.netmera.naturalworld",
            "paths": ["/products"]
        }]
    }
}

Handle Universal Links in the App

Implement the following method in your AppDelegate:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
  if (userActivity.activityType == NSUserActivityTypeBrowsingWeb) {
    let url = userActivity.webpageURL
    // Handle url
  }
  return true
}

User Experience

  • Using userActivity methods will prompt users with "Open in Safari or in the application?" when clicking a notification.

  • Handling Universal Links via Netmera Delegate methods (shouldHandleOpenUrl and handleOpenUrl) will direct users straight to the app.

- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
  restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
  if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
    NSURL *url = userActivity.webpageURL;
    // Handle url
  }
  return YES;
}

User Experience

  • Using userActivity methods will prompt users with "Open in Safari or in the application?" when clicking a notification.

  • Handling Universal Links via Netmera Delegate methods (shouldHandleOpenUrl and handleOpenUrl) will direct users straight to the app.

PreviousLive ActivitiesNextCustom Deep Links

Last updated 3 months ago

Was this helpful?

For further details, refer to the Apple documentation .

For further details, refer to the Apple documentation .

here
here