如何每两周通知UILocalNotification

时间:2016-08-15 17:55:03

标签: ios objective-c iphone notifications localnotification

早上好, 如何通知localNotification每两周(14天)发送一次通知。

- (void)applicationDidEnterBackground:(UIApplication *)application {

    timer = [NSTimer scheduledTimerWithTimeInterval:60*60*24*14 target:self selector:@selector(getNotifiedForTwoWeeks:) userInfo:nil repeats:YES];


}

-(void)getNotifiedForTwoWeeks:(id)userinfo{

        // Schedule the notification
    UILocalNotification* localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate =  [NSDate date];
    localNotification.alertBody = @"Notification Message";
    localNotification.alertAction = @"Show me the item";
    localNotification.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

请告诉我这个实施是否正确? 有没有其他方法可以让我们每隔两周通知一次LocalNotification消息。

非常感谢您的宝贵意见!

0 个答案:

没有答案