Skip to content

Deep linking - Swift

Deep linking consists of using a uniform resource identifier (URI) that links to a specific location within a mobile app rather than simply launching the app.

Examples of URIs that launch a mobile app:

  • twitter:// is the iOS URI to launch Twitter’s mobile app
  • YouTube:// is the iOS URI to launch YouTube’s mobile app

Pulse provides a “Deep linking” capability to pass data directly to an app for processing and performing interactions. Follow the instructions to use this feature in your app.

Add the PulseSDKDelegate protocol in your AppDelegate.swift file

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, PulseSDKDelegate

Set the delegate to self in didFinishLaunchingWithOptions method.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    PulseSDK.sharedClient().delegate = self;
}

Implement the delegate protocol in your AppDelegate.swift file.

The SDK will directly handle “http”, “tel” and “email” urls if a user clicks on a local notification to launch the app.

func didReceiveDeepLinkNotification(_ notification: String) {
    print(#function)
    print("Data received is" + notification)
    if notification.range(of:"http") != nil{
        //http url received
    }
    if notification.range(of:"tel") != nil{
        //tel url received
    }
    if notification.range(of:"mailto") != nil{
        //email url received
    }
    else{
        //app deep link
    }
}