2

I recently found out that, when my app was closed (I'm talking about it being completely closed, not in the background), any push with deeplink that I open will start the app, but that's it, the deeplink is never taken into account.

After investigating, I realized that when the app is closed and you open it via a push, application:didReceiveRemoteNotification is not called. It is up to the dev to check, in application:didFinishLaunchingWithOptions, the launchOptions dictionary, and look for the value of UIApplicationLaunchOptionsRemoteNotificationKey, meaning that the app was opened via a push.

Here's the description of launchOptions when opening my app in such a way :

Printing description of launchOptions:
{
    UIApplicationLaunchOptionsRemoteNotificationKey =     {
        aps =         {
            alert =             {
                "action-loc-key" = "_push-title_";
                body = "_push-budy_";
            };
            "content-available" = 1;
        };
        azme =         {
            au = "_deeplink-url_";
            ci = "a-1";
            dt = b;
            pid = 5130;
        };
    };
}

So, not knowing any other way, I have to check for the presence of a value for UIApplicationLaunchOptionsRemoteNotificationKey in the launchOptions, then get the value for the key "azme", and the value for the key "au", which seems like a totally wrong way to do it, and the open the URL as I normally do.

I could not find a better/more conventional way to do this, is there one ?

Thanks for the help !

CyberDandy
  • 470
  • 6
  • 17
  • It's correct approach to catch push notification in `application:didFinishLaunchingWithOptions`. You could extract PN handling code to external method and call it when application is launched with PN and if PN arrives during the app is launched. – brigadir Nov 28 '16 at 15:44

0 Answers0