我正在构建一个应用程序,我在地图上显示巴士站以及用户当前位置。我想实现通知,当用户说距离一个巴士站 x 米时,应该有一个通知,如警报、声音.这样他就可以为他的站点做准备。地图上可能有很多站点,我想为每个站点都做。请帮助我如何实现。是否是LocalNotification,然后如何以这种方式使用它............
提前致谢
我正在构建一个应用程序,我在地图上显示巴士站以及用户当前位置。我想实现通知,当用户说距离一个巴士站 x 米时,应该有一个通知,如警报、声音.这样他就可以为他的站点做准备。地图上可能有很多站点,我想为每个站点都做。请帮助我如何实现。是否是LocalNotification,然后如何以这种方式使用它............
提前致谢
在 中进行所有距离计算didUpdateToLocation
。
您可以在 iOS 4 中使用 UILocalNotification 类发送本地通知。
这是一些示例代码:
UILocalNotification *noti = [[UILocalNotification alloc] init];
noti.fireDate = someDate;
noti.alertBody = someText;
noti.alertAction = nil;
noti.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:noti];
[noti release];
确保日期尽可能接近 [NSDate date],这样它就会立即出现。