application didReceiveRemoteNotification not called on iOS 10 devices

When tapping on a push notification, the following method is not getting called on iOS 10 (beta 5) devices:


func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {...


This prevents us from being able to use deeplinking from push messages on iOS 10. The problem occurs when using Testflight builds created with Xcode 7.3. The method does get called successfully on iOS 9 devices.


I have not been able to test push functionality using the Xcode 8 beta because I've consistently been getting the following error on iOS 10 devices when trying to register for push notifications:


Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}


(I am getting this error via the didFailToRegisterForRemoteNotificationsWithError method)


This same app and provisioning profile is able to register and obtain a deviceToken just fine on iOS 9 devices using Xcode 8 and Xcode 7.3, and it also registers successfully on iOS 10 devices if you run it using a TestFlight build created with Xcode 7.3.

Accepted Reply

I am getting the same issue.

Current version of our app which built with Xcode 7, cannot deeplink from notifications on iOS 10 devices.


I figured out that iOS 10 calls

- application:didReceiveRemoteNotification:

instead of

- application:didReceiveRemoteNotification:fetchCompletionHandler:


So I had to implement the former method and call the latter inside.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult result) {
    }];
}


This is strange because it is against what is said in the documentation:


> Implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method instead of this one whenever possible. If your delegate implements both methods, the app object calls the application:didReceiveRemoteNotification:fetchCompletionHandler: method.

Replies

I am getting the same issue.

Current version of our app which built with Xcode 7, cannot deeplink from notifications on iOS 10 devices.


I figured out that iOS 10 calls

- application:didReceiveRemoteNotification:

instead of

- application:didReceiveRemoteNotification:fetchCompletionHandler:


So I had to implement the former method and call the latter inside.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [self application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult result) {
    }];
}


This is strange because it is against what is said in the documentation:


> Implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method instead of this one whenever possible. If your delegate implements both methods, the app object calls the application:didReceiveRemoteNotification:fetchCompletionHandler: method.

Xcode 7 copies the aps-environment entitlement from your provisioning profile. Turning on push notifications on Xcode 8 adds the entitlement both to your provisioning profile and the entitlements file.


Try adding the aps-environment entitlement to your app's entitlements file, or switch the notification capability off and on again.


--gc

See support article: http://support.iterable.com/hc/en-us/articles/212157066-iOS-10-Debugging-Push-Notifications-Not-Registering

The entitlements for Push Notifications in Capabilities probably needs to be turned on for XCode 8. This was a change from XCode 7 to XCode 8 for entitlements which no longer gets pulled from the Apple Developer App ID Identifiers.


-DT

hi gc,

the generated entitlement file are key and string as `aps-environment` : `development`

but how to configure for production aps-environment?

if I change the `aps-environment` to `production`, then the capability tab shows a red warning.

This works for basic setups, but for applications that span across multiple teams and different configurations, not using the profile as the source of truth seems to be a huge loss, we would now have to have an entitlements file for each build configuration to ensure the proper things get copied over into the right entitlement file for embedding 😟

Bump.


The guidance to "Try adding the aps-environment entitlement to your app's entitlements file" does not indicate what the value should be, and getting "development" as the default value (after clicking the "Add the push notification entitlement to your entitlements file") is worrying indeed.

The entitlements file should always have the aps-environment entitlement set to "development". The Xcode Organizer will update the entitlement in the app's signature to "production" when it re-signs the app for distribution.


You can confirm this by looking at the list of entitlements in the Summary sheet the Xcode Organizer presents when validating, uploading, or exporting an app for distribution.


--gc

No, that's not necessary. Please see my earlier reply about this.


--gc

That behavior is a bug that we believe is fixed in the iOS 10.1 beta 1. If you have a device to spare, please give that a try and file a new bug report if the issue persists.

--gc