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 (your_deeplink_scheme://).

  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

Implement the following method in your AppDelegate.swift to handle deep links:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
    print("openUrl: \(url)")
    return true
}

To handle universal links from Netmera push actions (e.g., https://your_domain/scheme?query):

  1. Set Netmera Push Delegate

In didFinishLaunchingWithOptions, add:

Netmera.setPushDelegate(self)

Ensure that your AppDelegate conforms to the NetmeraPushDelegate protocol.

  1. Implement Universal Link Handlers

Add the following methods to handle universal links:

  • shouldHandleOpenURL: Checks if the URL should be handled. Return true to process it.

  • handleOpenURL: Executes when the URL is triggered by a Netmera push action.

func shouldHandleOpenURL(_ url: URL, for pushObject: NetmeraBasePush) -> Bool {
	if url.host == "your_domain" {
		return true
	}
	return false
}

func handleOpenURL(_ url: URL, for pushObject: NetmeraBasePush) {
	print("openUrl \(url)")
}

Last updated

Was this helpful?