didReceiveRemoteNotification:fetchCompletionHandler not being called in background with content-available flag (gets called when connected to XCode)

℡╲_俬逩灬. 提交于 2019-12-07 02:18:42

问题


I'm having a really bizarre issue with push notification.

When the app is connected to Xcode (debug build), didReceiveRemoteNotification:fetchCompletionHandler acts like it's supposed to.

  • didReceiveRemoteNotification:fetchCompletionHandler is triggered when push is received when app is in the foreground
  • didReceiveRemoteNotification:fetchCompletionHandler is triggered when push is received when app is in the background
  • didReceiveRemoteNotification:fetchCompletionHandler is triggered when push is received and app is opened via notification center (from push)

However, when I build my app on my phone not using xcode:

  • didReceiveRemoteNotification:fetchCompletionHandler is
    triggered when push is received when app is in the foreground
  • didReceiveRemoteNotification:fetchCompletionHandler is NOT triggered when push is received when app is in the background
  • didReceiveRemoteNotification:fetchCompletionHandler is
    triggered when push is received and app is opened via notification center (from push)

To complicate things further:

For some ungodly reason, this just stopped working. Then, just randomly, it appears that it fixed itself (this was all in a span of 24 hours). However, about 5 minutes ago, it stopped working again. It also seems that some of my users are experiencing the same thing, while others are just fine.

I though it could be something wrong with the production push certificate, but then why I'm I receiving pushes? I'm totally lost here.

PS: The message payload template:

{
    aps =     {
        alert = "<message>";
        badge = 1;
        "content-available" = 1;
        sound = "layerbell.caf";
    };
    layer =     {
        "<convoId>";
        "<messageId>";
    };
}

Please note that this has nothing to do with a terminated state. I know that didReceiveRemoteNotification:fetchCompletionHandler will not be called if the app is terminated. This is not what the issue is.

来源:https://stackoverflow.com/questions/36297647/didreceiveremotenotificationfetchcompletionhandler-not-being-called-in-backgrou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!