Dan*_*n_R 6 geocoding geolocation geofencing
我目前正在使用"Regions"示例代码:https: //developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.h tml#// apple_ref/doc/uid/DTS40010726-Intro-DontLinkElementID_2
我想更进一步,当用户退出该区域时生成或触发通知(可以同时进入和退出,我不介意,对于初始实现最简单的事情).
我一直在查看CLLocation类参考,位置感知编程指南以及本地和推送通知编程指南.而我正在遭受信息超载.
非常感谢 :)
编辑:我想我可能有一个解决问题的想法:在RegionsViewController实现文件中有这样的:
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
[self updateWithEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
由于我想在用户退出指定区域边界时实现本地通知,我输入了以下内容:
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
[self updateWithEvent:event];
//implement local notification:
UIApplication *app = [UIApplication sharedApplication];
UILocalNotification *notification = [[UILocalNotification alloc] init];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
if (notification == nil)
return;
notification.alertBody = [NSString stringWithFormat:@"Did You Lock Your House?"];
notification.alertAction = @"Lock House";
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[app presentLocalNotificationNow:notification];
[notification release];
}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我这是否正确,或者是否有任何建议?(对格式不佳道歉)
| 归档时间: |
|
| 查看次数: |
3137 次 |
| 最近记录: |