简体   繁体   中英

Silent notification working weird in iOS7 without wifi

I'm using silent notifications, which works perfectly when my phone is plugged to Xcode, using Wifi, and with a breakpoint in the application:didReceiveRemoteNotification:fetchCompletionHandler: method, when my app is in background.

My server is sending a silent notification every minutes. Here is my payload :

{
    aps = 
    {
        "content-available" = 1;
    };
    "update-location" = 1;
}

BUT, when I disable the WIFI from my phone, it doesn't receive it anymore (3g is working as usual).

I got the same behavior when I'm not plugged to Xcode.

Does anyone have a idea, or already solved it?

I'd do the following two things first to help me narrow down the possibilities:

  1. Check what APNS gateway you're using. If you're using a distribution certificate, don't fire your notifications at the sandbox APNS URL.
  2. Make sure you're using the matching provisioning profile on the device. Development profiles & distribution profiles return different UDIDs.

Also, as Viruss mca said, sometimes there's a lag from Apple's servers.

UPDATE: You've also got a semi-colon in there.

aps = 
{
    "content-available" = 1;
};// << Right there. It should be a comma.

解决方案:将声音键添加到静默通知内容中。

I guess there may two points in your case,

  1. Dont send too many notifications to a device within a short span of time, coz APNS caches only 1 message/device (if the device is offline). So it can deliver the message when the device comes online. Am not sure how long the message is cached though.

  2. APNS is based on Apple Servers, and Apple doesn't give any guarantee on successful message delivery.

it quite clearly in the Apple Docs that it is not 100% gauranteed and nor should it be used as so

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM