iphone sdk到达时的本地通知 [英] Local Notification on arrival iphone sdk

查看:96
本文介绍了iphone sdk到达时的本地通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在这里的第一个问题,我真的希望有人能帮助我.

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.

我已经注册了该应用程序,以便在Info.plist文件中接收位置更新,并在didUpdateToLocation中进行所有距离计算.同样,如果应用程序位于前台而不是后台,则效果很好.

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.

谢谢.

推荐答案

您可以在iOS 4中使用

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

以下是一些示例代码:

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

不过,我不知道它是否可以在后台模式下工作.确保该日期与[NSDate日期]尽可能接近,因此它将立即显示.

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.

这篇关于iphone sdk到达时的本地通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆