didReceiveRemoteNotification:fetchCompletionHandler not being called when app is in background and not connected to Xcode

前端 未结 10 1707
别那么骄傲
别那么骄傲 2020-11-28 04:27

I\'ve a very strange problem, I implemented:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchComp         


        
10条回答
  •  天命终不由人
    2020-11-28 05:15

    This was an issue for me today and I was baffled.

    iOS: 10.2.1 xCode: 8.2.1 Swift: 3.0.2

    The issues was only on one phone I would get the packed only when plugged into xCode.

    I re-read Apples push documentation in case I missed something with the new UserNotifications framework and or messed something up with my code to fall back to the depreciated delegate functions for iOS 9.

    Anyway, I noticed this line in the documentation for application:didReceiveRemoteNotification:fetchCompletionHandler::

    "Apps that use significant amounts of power when processing remote notifications may not always be woken up early to process future notifications."

    It's the very last line on the page.

    While I wish Apple told me more, it turns out a simple phone restart solved the problem for me. I really wish I could figure out exactly what went wrong, but here are my very speculative conclusions:

    1) Push notifications were not being delivered to this app on this particular phone because of the line in the documentation mentioned above.

    2) When plugged into xCode iOS is ignoring the above, documented rule.

    3) I checked the (notoriously confusing) battery percentage calculator in system settings. It showed my app at a modest 6%, BUT Safari was a whopping 75% on this phone for some reason.

    4) After phone restart, Safari was back down to about 25%

    5) Push worked fine after that.

    So... My ultimate conclusion. To weed out the documented battery issue either try a phone restart or try a different phone and see if the problem persists.

提交回复
热议问题