application:didReceiveRemoteNotification:fetchCompletionHandler not called on iOS 11

Hi,

I'm relying in the UIApplicationDelegate method "application:didReceiveRemoteNotification:fetchCompletionHandler" to receive some silent notifications when the application is not in the foreground.


With iOS 11 beta 1, this method is no longer called when I send this push payload


{
  "aps": {
    "content-available": 1
  },
  "mydata": {
    "foo": "bar"
  }
}



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


Did anybody else noticed this behaviour?

Replies

It looks like it's is still not fixed in iOS 11b2

I see the same issue -- but only when the app is suspened. Have you found a fix for this.

So this was indeed a bug in iOS 11 and it's now fixed in iOS 11 beta 3. The `application:didReceiveRemoteNotification:fetchCompletionHandler` is now called correctly when a silent push is received both in foreground or in background.

It's still not working for me on iOS 11 beta 3 (15A5318g).


application:didReceiveRemoteNotification:fetchCompletionHandler:


is not called when the app is in background. The same code works on a device with iOS 10.3.2 (14F89). Are there any changes that I should be aware between iOS 10 and iOS 11 regarding this?

Are you sure? No, there aren't any changes in the implementation of silent pushes. Did you set the correct app capabilities?

Yes, as I said the same build works as expected on iOS 10. It also works when I run the app from XCode and send it to background, but otherwise nothing happens if I get a remote notification and the application is sleeping. I will try to configure everything from scratch again, maybe I missed something.

You are right, I see now again the same buggy behaviour :/

Hi, do you know if there is a place to track the progress of this bug. It is happening to us as well where didReceiveRemoteNotification is not getting called on iOS 11. We're testing with beta 4. Please advise. Thanks!

no updates in the bug report. I’ll post back if there is anything

in beta 5, i confirmed still existed this issue


this is how our swift function definied, anyone are using @escaping ? was that the root cause?


func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

Same for me. Still happening in beta 5. I noticed that it is a bit random. Sometiemes, after restarting the device, the silent push is correctly delivered but then it stops working after a while.


Btw, here is a sample project where the issues is reproduced.

https://www.dropbox.com/s/qdk3dh9irpsmbgi/PushBug11.zip?dl=0


@Jacob.Jiang, yes the @escaping is how the method is defined.

still happening in beta6


instead, sometimes it will active app in background and run sometimes, but sometime don't active at all. Isn't that was supposed to run everytime receive a silent push notification?


Here is a sample log, we receive this notification and manually click that one, the payload is clearly correct, but app didn't wake up. Stupid iOS11, why the **** change this behavior and nothing related announced in WWDC video.



userNotificationCenter(_:didReceive:withCompletionHandler:):[AnyHashable("posts"): <__NSSingleObjectArrayI 0x1c4614bb0>(

{

"_id" = 2399790817284;

"at_mention_item_ids" = (

);

"at_mention_non_item_ids" = (

999751683

);

"company_id" = 1233543169;

"created_at" = 1502848878686;

"creator_id" = 2454224899;

deactivated = 0;

"function_id" = post;

"group_id" = 8554250242;

"is_new" = 1;

"item_ids" = (

);

items = (

);

"model_size" = 0;

"modified_at" = 1502848878686;

"post_ids" = (

);

text = "<a class='at_mention_compose' rel='{\"id\":999751683}'>@Jacob Jiang</a> jfdls;ajkfl;das";

version = 3609024584508582;

}

)

, AnyHashable("items"): <__NSArray0 0x1c00179d0>(



)

, AnyHashable("unread"): 0, AnyHashable("aps"): {

alert = "Test Jiang4 mentioned you: @Jacob Jiang jfdls;ajkfl;das";

badge = 0;

category = "NEW_GLIP_MSG";

"content-available" = 1;

"mutable-content" = 1;

sound = default;

}, AnyHashable("group_id"): 8554250242]

I have the same problem with iOS 11 Beta 7. Same build of my app running on iOS 10 and iOS 11:


iOS 10 - everthing ok

iOS 11 - push messages arrive at thevice (as seen in console) but do not get delivered to application:didReceiveRemoteNotification: if the app is running in foreground

I think I've just found the issue. I had content-available set to true in my push message body but did not have "Remote notifications" enabled for my app in Xcode. This combination seems to not deliver the push message to the app any more. It used to work fine up until iOS 10.

What do you mean by ""Remote notifications" enabled for my app in Xcode" ?