If the app is already open or in the background, and a push notification is sent to the device then sfmc_handle(_ url: URL, type: String) is fired properly. Everything works as expected as the link attached to the push notification is handled.

But if the app is closed, and a push notification is tapped to open the app then sfmc_handle(_ url: URL, type: String) never triggers.

In our app, MarketingCloudSDK.sharedInstance().sfmc_configure(with: builder) is called at the beginning of the AppDelegate's didFinishLaunchingWithOptions(), and the delegate is set immediately once the configuration is successful:


Based on the SDK documentation for iOS, all of this is setup properly. It seems that perhaps when the app is launched from a "cold start" the delegate hasn't been fully configured by the time the url is passed to the app from the push notification.

But if this is the case, then what is missing in the configuration setup? Or is this a bug in the iOS SDK?

Does it matter if we have this in the builder sfmc_setDelayRegistration(untilContactKeyIsSet: true)?

1 Answer 1


As you know, the SDK relies on the implementer to pass the notification to it in order to handle urls, report correct analytics etc. There are 2 things to verify:

  1. The SDK is initialized when passed the notification.
  2. The notification is intercepting the notification from Apple's delegate methods and passing it to the SDK correctly.

For your situation I believe you are setting the delegate and initializing the SDK in the correct places. The issue is not correctly intercepting the notification when coming from a closed app state. Apple has indicated that intercepting remote notifications from a closed app state can be done via the launchOptions in application(_:didFinishLaunchingWithOptions:) or in iOS 13 the connectionOptions in scene(_:willConnectTo:options:). I have provided 2 examples below verifying the SDK is configured and then intercepting the remote notification:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

       let result = configureMarketingCloudSDK() // Example method to configure the SDK

       if let launchOptions = launchOptions,
           let userInfo = launchOptions[.remoteNotification] as? [AnyHashable: Any], result {
       return result

For iOS 13 SceneDelegate

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

   let result = configureMarketingCloudSDK() // Example method to configure the SDK
   if let response = connectionOptions.notificationResponse, result {

   guard let _ = (scene as? UIWindowScene) else { return }

In here feel free to extract out the url from the notification payload (userInfo) and pass it to sfmc_handleUrl

Finally, from our sdk docs: "The below method will be invoked even if the application was launched or resumed because of the remote notification. The respective delegate methods will be invoked first. Note that this behavior is in contrast to application:didReceiveRemoteNotification:, which is not called in those cases, and which will not be invoked if this method is implemented."

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
  • 1
    So the appDelegate launchOptions did not work. I assume it's because we're targeting iOS 14.0 and above? We implemented the SceneDelegate with connectionOptions and that solved it. Now we're getting push notifications to be handled when the app is closed so we can then parse the incoming Url for deep linking. Thanks Skyler!
    – Brooks
    Jun 18, 2021 at 1:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .