Is it something like service in Andorid on IOS Which would be work in background from start System ? I play witch beacons and I would like to send notification when user is near beacon. It is possible on IOS ?
Regards
Is it something like service in Andorid on IOS Which would be work in background from start System ? I play witch beacons and I would like to send notification when user is near beacon. It is possible on IOS ?
Regards
Only certain apps are allowed to do this. See https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW24 for a full explanation of background modes.
In short apps can be suspended at any time when in the background, the exceptions are apps that request specific permissions to exeute uninterrupted in the backgrounded (like voip apps or music apps) but apple may reject your app store submission if you request such permissions and your app doesn't actually provide any related functionality.
You can do things in background but it does not work like on Android. iOS will call a particular method to give you the chance to update, then you have a limited time to do so.
You can still ask more time when the app is returning to background (roughly around 10 minutes). Check out beginBackgroundTaskWithExpirationHandler method
Another solution is to use the significant location changes. If user shares his location with your app, you can get a callback when his position changes, and use this time to refresh.
I know dropbox app uses the location solution to upload your photos on the go from your camera roll to their services.
Yes. Check out Apple's Documentation for location monitoring.
From the docs
In iOS, regions associated with your app are tracked at all times, including when the app isn’t running. If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event. Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds) to handle the event. When necessary, an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler: method of the UIApplication class.
You'll likely have to add "Location Updates" as an allowed background mode for your application. I'm not sure if you have to enable "Uses Bluetooth LE accessories" or "Acts as a Bluetooth LE accessory", or maybe neither.
Create a beacon region for the UUID you want to monitor. See Apple's docs again.
- (void)registerBeaconRegionWithUUID:(NSUUID *)proximityUUID andIdentifier:(NSString*)identifier {
// Create the beacon region to be monitored.
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc]
initWithProximityUUID:proximityUUID
identifier:identifier];
// Register the beacon region with the location manager.
[self.locManager startMonitoringForRegion:beaconRegion];
}
Handle the location manager's delegated method:
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
You'll probably want to trigger a local notification when handling the event. Apple's docs on local notifications.