额外通知提醒

时间:2017-05-31 05:14:04

标签: ios objective-c

我为我的应用使用了通知提醒,并使用了以下代码

if(condition){
    [defaults setBool:YES forKey:@"notificationIsActive"];
    [defaults synchronize];

    //self.message.text=@"Notifications Started";
    NSTimeInterval interval;
    interval = 5;
    UILocalNotification* localNotification = [[UILocalNotification  
    alloc] init];
    localNotification.fireDate = [NSDate 
    dateWithTimeIntervalSinceNow:interval]; //Enter the time here in 
    seconds.
    localNotification.alertBody= @"Alert time";
    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    localNotification.repeatInterval= 
    NSCalendarUnitDay;//NSCalendarUnitMinute;
//Repeating instructions here.

localNotification.soundName= UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

}

else
{
    NSArray *arrayOfLocalNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications] ;

    for (UILocalNotification *localNotification in arrayOfLocalNotifications) {

        if ([localNotification.alertBody isEqualToString:@"Alert time"]) {
            NSLog(@"the notification this is canceld is %@", localNotification.alertBody);

            [[UIApplication sharedApplication] cancelLocalNotification:localNotification] ; // delete the notification from the system

        }

    }
}

现在问题是我收到了显示this is message Users will see的额外通知。我检查了所有没有额外通知警报我添加的内容。现在我该怎么办?请帮忙..

编辑: 缺少一点。我在我的应用中使用了该通知进行测试,但之后我删除了该通知。

0 个答案:

没有答案