1

使用してUILocalNotificationいますが、時間通りに発射されず、指定された時間の 8 ~ 10 分後に通知されます。これが私が使用しているコードです

    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
    [dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *dateString = [dateFormat stringFromDate:[NSDate date]];
    NSDate *notificationDate = [dateFormat dateFromString:dateString];
    localNotif.fireDate = notificationDate;
    localNotif.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];

    // Notification details
    localNotif.alertBody = @"Appear";
    // Set the action button
    localNotif.alertAction = @"Action";

    localNotif.soundName = UILocalNotificationDefaultSoundName;

    // Schedule the notification
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

のdidEnterRegionデリゲートでこれを使用していCLLocationManagerます。私は何を間違っていますか?

4

1 に答える 1

3

これは作業コードです:

UILocalNotification* n1 = [[UILocalNotification alloc] init];
n1.fireDate = [NSDate dateWithTimeIntervalSinceNow: 60];
n1.alertBody = @"one";
UILocalNotification* n2 = [[UILocalNotification alloc] init];
n2.fireDate = [NSDate dateWithTimeIntervalSinceNow: 90];
n2.alertBody = @"two";
[[UIApplication sharedApplication] scheduleLocalNotification: n1];
[[UIApplication sharedApplication] scheduleLocalNotification: n2];
于 2013-05-07T08:30:20.403 に答える