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

前端 未结 10 1687
别那么骄傲
别那么骄傲 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:16

    TL;DR: Use Test Flight in iTunes Connect
    

    Maybe some of you guys already figured out this, but I posting here since I don't see a clear answer.

    The had the exact same problem describe. Silent push notifications worked while the Lightning cable was connected. Stopped working when I disconnected the cable. I had every NSLog and network call tracked to prove that was indeed happening.

    I was using the payload suggested in many answers, as well as this one:

    {
        "aps" : {
            "content-available": 1,
            sound: ""
        }
    }
    

    After many hours, I discovered that the issue is related to Adhoc and Development provisioning profiles, on iOS 8.0, 8.1 and 8.1.1. I was using Crashlytics to send beta versions of my app (that uses Adhoc profile).

    The fix is:

    In order to have it working, try out Apple's Test Flight integration with iTunes Connect. Using that you will send an Archive of your app (the same archive to be used on App Store) but enable your binary to be used in beta. The version installed from Test Flight probably (I can't prove) uses the same Production Provisioning Profile from the App Store, and the app works like a charm.

    Here's a link that helps set up the Test Flight account:

    http://code.tutsplus.com/tutorials/ios-8-beta-testing-with-testflight--cms-22224

    Not even a single Silent Payload was missed.

    I hope that helps someone not to lose a whole week on this issue.

提交回复
热议问题