0
最近我試圖創建一個鬧鐘,並且當我使用UILocalNotification時,會出現問題。它將在應用程序處於後臺時顯示橫幅,但當應用程序處於活動狀態時,即使認爲我使用了didReceiveLocalNotification,也沒有任何反應。 爲什麼?didReceiveLocalNotification在iOS6中未激活
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
UIApplicationState state = application.applicationState;
if (state == UIApplicationStateActive) {
NSLog(@"RingRingRing~~~~~");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Remind" message:notification.alertBody delegate:self cancelButtonTitle:@"Sure" otherButtonTitles:nil, nil];
[alert show];
}
}
對不起..但我不明白你的觀點..你可以用更多的細節解釋它嗎? thx – ArexChow 2013-02-27 09:27:27
這是否意味着我必須編寫一個didReceiveLocalNotification:在AppDelegate.m中? – ArexChow 2013-02-27 12:26:30
當您的應用程序處於活動狀態時,正在調用didReceiveLocalNotification - 在這種情況下,此調用將取代實際的通知。 當您的應用程序未處於活動狀態時,只有當用戶按下按鈕時,纔會獲得已啓動的信息。 – Ugster 2013-08-26 18:42:28