Я ищу способ реализации уведомлений на основе геоинформации на iOS.
Я нашел два пути, но я не мог понять, какой из них лучший и какая разница.В чем разница между этими подходами на основе геообъектов в iOS?
1: Использование startMonitoring CLLocationManager Как этот учебник. https://www.raywenderlich.com/136165/core-location-geofencing-tutorial
2: Использование области startMonitoring CLLocationManager и области UILocalNotification.
Как этот код:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.alertBody = [NSString stringWithFormat:@"Hello!"];
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
CLCircularRegion *region = nil;
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(geoPoint.latitude,
geoPoint.longitude);
if (CLLocationCoordinate2DIsValid(location)){
region = [[CLCircularRegion alloc] initWithCenter:location
radius:50.0
identifier:@"region1"];
region.notifyOnExit = NO;
localNotif.region = region;
localNotif.regionTriggersOnce = YES;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
} else {
NSDictionary *info = @{NSLocalizedDescriptionKey:@"Invalid coordinate info."};
NSError *error = [NSError errorWithDomain:@"InvalidCLLocationError"
code:1999
userInfo:info];
}