简体   繁体   中英

ios - significant location change, and no Internet

I am using Significant Location Changes, and this is working fine. I then call a web api, and pass location data to this.

However, when I am not connected to the Internet, it cannot send the message.

How do I get around this? I have tried putting a sleep into a recursive send routine.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [NSThread sleepForTimeInterval:5.0f];
        [self postURL :post :function];
    });

This works fine with the app in the foreground. It cannot send the message but will keep retrying, when the Internet is available it then sends the message, but when it is in the background it will call the postURL only once, the first time around the function.

How can I get around this? Or is there a better way to get background notifications when the Internet is lost, and reconnected.

Found a solution to this, switched to using startUpdatingLocation rather than using startMonitoringSignificantLocationChanges .

This now seems to work.

I don't think startMonitoringSignificantLocationChanges is suitable for sending location data back to a server.

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