Geolocation with local notification like reminder

邮差的信 提交于 2019-11-30 07:45:52
Bill Burgess

I can tell you that your radius is more than likely too small to actually trigger an update. You have the radius set to 1 meter. That is going to take a location update almost too precise to register on anything other than testing coordinates you pass in.

Assuming you get a region event, I would put your local notification in the -didEnterRegion or -didExitRegion methods. You can create your notification like @Missaq said.

UILocalNotification *notification = [[UILocalNotification alloc] init]; 
notification.fireDate = [NSDate date]; 
NSTimeZone* timezone = [NSTimeZone defaultTimeZone]; 
notification.timeZone = timezone; 
notification.alertBody = @"Notification message"; 
notification.alertAction = @"Show"; 
notification.soundName = UILocalNotificationDefaultSoundName; 
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release]; // release if not using ARC

Keep in mind that you will not get your notification if your application is active. You will have to be in background mode if you want to see your notification fire. If you application is active, you are expected to present an UIAlertView rather than UILocalNotification. Hope this helps.

Try to use the

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;

and

- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;

delegate methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!