我想提醒用户基于时间,但不能实现使用这段代码,请给我任何solution.This是我的代码:
NSDate *pickerDate = [self.StartDate date];
    UIApplication* app = [UIApplication sharedApplication];
    UILocalNotification* notifyAlarm = [[UILocalNotification alloc] init];
    NSDate *date1=[pickerDate dateByAddingTimeInterval:60];
    notifyAlarm.fireDate = date1;
    notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
    //notifyAlarm.timeZone = [NSTimeZone defaultTimeZone];
    notifyAlarm.repeatInterval =NSCalendarUnitWeekday;
    notifyAlarm.soundName =UILocalNotificationDefaultSoundName;
    notifyAlarm.alertBody =self.EventText.text;
    //notifyAlarm.alertLaunchImage=@"in.png";
    [app scheduleLocalNotification:notifyAlarm];
    [self dismissViewControllerAnimated:YES completion:nil];发布于 2016-06-19 11:57:25
在appDelate.m中用didFinishLaunch方法编写这段代码
 if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
            UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                            UIUserNotificationTypeBadge |
                                                            UIUserNotificationTypeSound);
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
                                                                                     categories:nil];
            [application registerUserNotificationSettings:settings];
            [application registerForRemoteNotifications];
        } else {
            [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                             UIRemoteNotificationTypeAlert |
                                                             UIRemoteNotificationTypeSound)];
        }https://stackoverflow.com/questions/37880060
复制相似问题