Local Notification on arrival iphone sdk

蓝咒 提交于 2019-12-11 16:02:24

问题


this is my first question here and I am really hoping someone 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.


回答1:


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.



来源:https://stackoverflow.com/questions/5381379/local-notification-on-arrival-iphone-sdk

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