2017-03-03 1 views
0

Je veux définir une notification qui se répète tous les 14 jours (2 semaines) .J'utilise l'ancien cadre de notification "UILOCAL NOTIFICATION" comme je le veux Ne travaillez pas avec ios 9.Est-il possible de définir une notification qui se répète tous les 14 jours en utilisant UILocal Notification ios 9

+0

Je pense que ce lien vous aidera à: répéter une notification locale quotidienne/horaire [http://stackoverflow.com/questions/3426882/iphone-how-to-set-repeat-daily-hourly-local-notification] et un intervalle de temps personnalisé [http://stackoverflow.com/questions/4363847/how -to-set-local-notification-repeat-intervalle-to-custom-time-interval] – Nazir

Répondre

1

Soit vous devez faire comme cette réponse dit: Repeating a Local Notification after every 14 days(two weeks)? ou vous devez laisser votre application gérer cela en programmant une notification locale pour la première occurrence, puis lorsque cette notification est reçue par votre application, reprogrammer pour 14 jours supplémentaires.

1

Oui vous pouvez le faire easly,

Epic: Lorsque l'utilisateur quitte l'application, nous avons mis en UINotification puis de l'envoyer. si l'utilisateur n'entrent pas dans 2 jours (2 * 24 * 60 * 60), la notification enverra la fin des 2 jours. si vous voulez envoyer au bout de 14 jours, vous pouvez modifier l'heure fireDate avec 14 * 24 * 60 * 60

dans 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

et qu'en est-il de repeatInterval ?? doit-il être réglé sur NSCalendarUnitDay ?? – kishan