Я написал приложение для геозащиты, и он отлично работает, когда он работает на переднем плане и в фоновом режиме. И как заставить это приложение работать и отправлять уведомления о геообъектах даже в случае, когда приложение убито?Geofencing in iPhone
0
A
ответ
0
Когда приложение будет убито, iOS по-прежнему будет контролировать геообъекты. Если вы введете или выйдете из него, будет вызван ваш AppDelegate application:didFinishLaunchingWithOptions:
. Вы можете обнаружить, будет ли это место запуска с параметрами запуска:
if (launchOptions[UIApplicationLaunchOptionsLocationKey])
{
//Re-Setup your location manager and take appropriate action. The locationManager:didEnterRegion: locationManager:didExitRegion delegate of the new location manager will be triggered.
}
0
Вы также можете создать оповещение в то время, когда вы начинаете мониторинг вашего региона:
[self.locationManager startMonitoringForRegion:region];
UILocalNotification *regionNotification = [UILocalNotification new];
NSString *notificationString = [NSString stringWithFormat:@"You are approaching near region%@",region.identifier];
regionNotification.alertBody = notificationString;
regionNotification.alertAction = @"Show me the region details.";
regionNotification.region = region;
regionNotification.regionTriggersOnce = NO;
regionNotification.userInfo = [NSDictionary dictionaryWithObject:region.identifier forKey:@"regionIdentifier"];
[[UIApplication sharedApplication]scheduleLocalNotification:regionNotification];
Это уведомление будет работать на все 3 условия:
- , когда приложение находится на переднем плане
- , когда приложение находится в фоновом режиме
- , когда приложение будет убит
функции обратного вызова для уведомления всех трех случаев принимаются в UIApplicationDelegate
методы - application:didReceiveLocalNotification:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
//Do whatever you want after you receive the notification
}
Смежные вопросы
- 1. Geofencing in iOS 10
- 2. Android Geofencing
- 3. Алгоритм Geofencing
- 4. iOS - Geofencing with WiFi отключен
- 5. Geofencing сделалEnterRegion, didExitRegion функция не звоните в iphone 5S iOS8.1
- 6. Geofencing Intent Not Firing
- 7. GeoFencing не работает
- 8. Geofencing not triggering
- 9. iOS Geofencing with CoreLocation
- 10. Geofencing Alert Analytics - Невозможно?
- 11. GeoFencing on iOS
- 12. Android Geofencing (Polygon)
- 13. GeoFencing alternate for geomoby
- 14. Ios Native Geofencing сомнений
- 15. GeoFencing Best Stratigies
- 16. Geofencing with Javascript
- 17. Индикатор пустотелого положения Geofencing
- 18. Geofencing и GoogleApiClient
- 19. Ограничение Geofencing с Android
- 20. Android GeoFencing Dwell
- 21. Windows Band Tile GeoFencing
- 22. Android Geofencing - Нет намерений?
- 23. Geofencing and Lollipop
- 24. IOS Geofencing background alert
- 25. Swift 3 Проблемы с Geofencing
- 26. Geofencing не отправляет уведомление (iOS)
- 27. Geofencing: GoogleApiClient еще не подключен
- 28. Android new LocationSettings and Geofencing
- 29. Cordova Плагин Geofencing не работает
- 30. Запуск Geofencing On Boot Завершено