i want implement geolocation notification like the app reminders. this is what i have already done:
in App delegate:
self.locationMa
Try to use the
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;
and
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;
delegate methods.
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.