开发者

Local Notification on arrival iphone sdk

this is my first question here and I am really hoping some开发者_StackOverflowone can help me.

I have a navigation app that displays an alertview to the user when they arrive at their destination. This works perfectly fine, but I want to alert the user through a localnotification in the same manner when they arrive and the app is in the background.

I have registered the app to receive Location updates in the Info.plist file, and do all my distance calculations in didUpdateToLocation. Again, this works perfectly well if the app is in the foreground just not when its in the background.

If there is any help or ideas anyone can provide me it would be highly appreciated.

Thank you.


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];

I don't know if it will work in background mode, though. Make sure the date is as close as posible as [NSDate date], so it will appear right away.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜