Inconsistent remote notification delivery behaviour between iOS 10 and previous iOS releases

Originator:stefanprutianu
Number:rdar://28386845 Date Originated:20-Sep-2016
Status:Closed (Duplicate of rdar://27940438) Resolved:10-Oct-2016
Product:iOS SDK Product Version:iOS 10
Classification:Bug Reproducible:Always
 
Summary:

On iOS 10, the remote notification payload it is not delivered to the app as stated in the documentation, when the notification banner is tapped in contrast with the behaviour on previous iOS releases.

Detailed description: 

The UIApplicationDelegate API reference states that the remote notification payload, when tapping the associated banner, will be delivered to the application via 

A)
- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;

instead of 

B) 
- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo;

when both are implemented.

However on iOS 10 the later is used instead when bringing the app from background to foreground by tapping on the notification banner. If the later is not implemented the notification banner is not delivered to the app when banner is tapped.

Examples:
1) Notification payload does NOT contain "content-available" key
a) iOS 8.4/iOS 9.2.1, app in foreground, notification arrives and it is delivered via A) -> OK
b) iOS 8.4/iOS 9.2.1, app in background, tap on banner, notification delivered via A) -> OK
c) iOS 10.0.1(14A403), app in foreground, notification arrives and it is delivered via A) -> OK
d) iOS 10.0.1(14A403), app in background, tap on banner, notification delivered via B) -> NOT OK

2) Notification payload does contain "content-available" key
a) iOS 8.4/iOS 9.2.1, app in background, notification arrives and it is delivered via A), tap on banner, notification delivered via A) -> OK
b) iOS 10.0.1(14A403), app in background, notification arrives and it is delivered via A) (OK), tap on banner, notification delivered via B) -> NOT OK

This iOS 10 inconsistency has the potential of breaking the remote notification handling for many applications which only implemented the newer API, i.e. - (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler; according to documentation.

Steps to Reproduce:
- using Xcode 7.3 (or Xcode 8 GM)
- using iPhone devices running iOS 8.4, iOS 9.2.1 and iOS 10.0.1(14A403) respectively
- using Knuff (https://github.com/KnuffApp/Knuff/releases) or a similar tool to send push notifications

1) Open the "PushNotificationsTest.xcodeproj" in the attached directory
2) Configure signing for push notifications for your specific configuration
3) Run the PushNotificationsTest target on your device
4) Search in Xcode Console for a log "Device token: *********" and extract your device token
5) With app in foreground, send a push notification. Confirm breakpoint in - [AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] is hit.
6) With app in background, send a push notification. Open the app via notification banner. Confirm breakpoint in - [AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] is hit.

Expected Results:
The breakpoint in - [AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] will be hit at both steps 5) and 6)

Actual Results:
The breakpoint in - [AppDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] is hit only at step 5) 

The breakpoint in - [AppDelegate application:didReceiveRemoteNotification] is hit instead at step 6) 

Version:
 iOS 8.4 (12H143), iOS 9.2.1 (13D15) and iOS 10.0.1(14A403)

Notes:
Sample push payload:

{
	"aps": {
		"alert": "Sample push message",
		"badge": 1,
		"sound": "default"
	}
}

Similar to this one: http://www.openradar.me/27822963

Configuration:
2 x iPhone 5c, iPhone 6 Plus

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!