2015-01-21 65 views

回答

0

我已經使用以下hack實現了這種功能。

- (void)application:(UIApplication *)application didReceiveLocalNotification 
(UILocalNotification *)notification 
{ 
    if ([notification.alertBody isEqualToString:@"your notification's alertBody"]) 
    { 
     //reschedule your notification for 2 months 
    } 
} 

只是在你的應用程序的委託appdelegate.m

+0

的比較時,用於識別通知已被炒到推通知網絡服務?沒有比alert機體更加優雅的方式嗎? – mrd 2015-01-21 12:14:48

+0

我使用了alertBody,因爲它在我的情況中是獨一無二的。你是否使用了一些類似的LocalNotification的alertBody? – 2015-01-21 12:16:08

+0

是的,它是確定localnotification – 2015-01-21 12:16:32

0

用上面的方法不幸的是不可能的。 NSCalendarUnit僅適用於單位重複。
考慮到您無法安排超過64個本地通知,您有3種可能性。

  1. 如果你知道,絕不會超過這個限制,安排所有的通知要求
  2. 做一個算法,安排剛剛通知的量,當用戶在您的應用程序中輸入刪除舊的通知,並重新安排多個通知。要做到這一點識別每個通知與一個ID並將其附加到信息詞典。
  3. 創建註冊用戶選項,並使用一臺服務器需要(推送通知)