2017-03-03 5 views
0

Ich möchte eine Benachrichtigung, die alle 14 Tage (2 Wochen) wiederholt. Ich benutze alten Benachrichtigungsrahmen "UILOCAL BENACHRICHTIGUNG", wie ich es will arbeiten nur mit IOS 9.Ist es möglich, eine Benachrichtigung, die alle 14 Tage wiederholt UILocal Notification ios 9

+0

Ich denke, diese Links werden Ihnen helfen: täglich wiederholen/stündlich lokale Meldung [http://stackoverflow.com/questions/3426882/iphone-how-to-set-repeat-daily-hourly-local-notification] und benutzerdefinierte Zeitintervall [http://stackoverflow.com/questions/4363847/how -zu-set-local-notification-repeat-interval-to-custom-time-interval] – Nazir

Antwort

1

Entweder Sie müssen tun, wie diese Antwort sagt: Repeating a Local Notification after every 14 days(two weeks)? oder Sie müssen Ihre App damit umgehen, indem Sie eine lokale Benachrichtigung für das erste Vorkommen planen, und dann, wenn diese Benachrichtigung von Ihrer App empfangen wird, planen Sie neu es für weitere 14 Tage.

1

Ja Sie easly tun können,

Epos: Wenn der Benutzer die App verlassen, setzen wir UINotification und abzusenden. Wenn der Benutzer nicht in 2 Tagen eintritt (2 * 24 * 60 * 60), sendet die Benachrichtigung Ende der 2 Tage. Wenn Sie nach 14 Tagen senden möchten, können Sie die fireDate Zeit ändern mit 14 * 24 * 60 * 60

in AppDelegate:

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
    UILocalNotification *notification = [[UILocalNotification alloc] init]; 
    notification.timeZone = [NSTimeZone defaultTimeZone]; 
    notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:2*24*60*60]; 
    //[[NSDate date] dateByAddingTimeInterval:5];[NSDate dateWithTimeIntervalSinceNow:24*60*60] 
    NSLog(@"%@",notification.fireDate); 
    notification.alertBody = NSLocalizedString(@"NOTIFICATION_MSG", @"Message"); 
    notification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1; 
    [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 

} 


- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
    [[UIApplication sharedApplication] cancelAllLocalNotifications]; 
    application.applicationIconBadgeNumber = 0; 
} 
+0

und was ist mit repeatInterval? muss es auf NSCalendarUnitDay eingestellt werden? – kishan

Verwandte Themen