我有一个应用程序寄存器位置更新,运行测试,有时当我进入一个区域,而应用程序是在我收到一个带声音的报警通知的背景。 有时我只看到在通知中心通知,我没有收到任何声音和提醒...你能做些什么来总是声音和警报通知?
这就是我在我的观点
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = nil;
localNotif.hasAction = YES;
localNotif.alertBody = fbName;
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotif];
这是应用程序的委托
- (void)application:(UIApplication *)application didReceiveLocalNotification (UILocalNotification *)notification
{
if (notification)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert"
message:notification.alertBody
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];
UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (notification)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert"
message:notification.alertBody
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
return YES;
}