Question

I am building an application where i show the bus stops on the map and the user current location as well.I want to implement the notification that when the user is say x meters from one bus stop ,there should be a notification like alert,sound .So that he can prepare for his stop.There may be many stops on the map and i want to do it for everystop. Please help me how to implement that.Whether it would be LocalNotification,Then how to use this in this way..........

Thanks in advance

Was it helpful?

Solution

Do all your distance calculations in didUpdateToLocation.

You can send local notifications in iOS 4, using UILocalNotification class.

Here is some sample code:

UILocalNotification *noti = [[UILocalNotification alloc] init];
noti.fireDate = someDate;
noti.alertBody = someText;
noti.alertAction = nil;
noti.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:noti];
[noti release];

Make sure the date is as close as possible as [NSDate date], so it will appear right away.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top