Why doesn't my app open when notification content extension calls completionHandler with DismissAndForward?

In my notification content extension, I am displaying a custom view along with 2 quick action buttons.


One of the buttons is "Open in App" - when this button is tapped, the content extension class's didReceiveNotificationResponse:completionHandler: is called and if the actionIdentifier matches the Open in App button, I call this:


completionHandler(UNNotificationContentExtensionResponseOptionDismissAndForwardAction);


At this point, breakpoints in my app's App Delegate are fired and the debugger stops in my App Delegate in my notification handler code, just as I expected it would (amen). The code then deciphers the notificaiton and opens the appropriate content's view controller. All this happens correctly, I can see it executing in the debugger.

But, on the screen - Nothing. Spotlight. Once the Notification is dismissed (and control passes to the App) nothing is on the screen except Spotlight.

And here's the rub, if I tap on my App icon in Spotlight, it opens up and sure enough, its sitting there waiting on the content view controller which was loaded during PUSH processing.


But nothing on the screen - what am I doing wrong?


Here is my code for didReceiveNotificationResponse:completionHandler:


- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(UNNotificationContentExtensionResponseOption))completionHandler
{
    NSString* actionID = [response actionIdentifier];
    if ([actionID isEqualToString:@"OpenInApp"])
    {
        completionHandler(UNNotificationContentExtensionResponseOptionDismissAndForwardAction);
    }
    else if ([actionID isEqualToString:@"ShowPageTwo"])
    {
        [self showPage:2];
        completionHandler(UNNotificationContentExtensionResponseOptionDoNotDismiss);
    }
    else
    {
        completionHandler(UNNotificationContentExtensionResponseOptionDismiss);
    }
}

Accepted Reply

It turned out I was mistakenly setting the options for the notification action to "UNNotificationActionOptionNone" instead of "UNNotificationActionOptionForeground".


// correct

UNNotificationAction *action = [UNNotificationAction actionWithIdentifier:@"OpenInApp" title:@"Open in App" options:UNNotificationActionOptionForeground];


I completely overlooked this. Trees in the forest or something something? Ugh. Working fine now.

Replies

It turned out I was mistakenly setting the options for the notification action to "UNNotificationActionOptionNone" instead of "UNNotificationActionOptionForeground".


// correct

UNNotificationAction *action = [UNNotificationAction actionWithIdentifier:@"OpenInApp" title:@"Open in App" options:UNNotificationActionOptionForeground];


I completely overlooked this. Trees in the forest or something something? Ugh. Working fine now.