如何在活动状态下显示本地通知,就像它在非活动状态中显示的那样

时间:2016-05-17 08:32:51

标签: ios objective-c notifications

我目前正在这样做,但通知会重复多次。请帮助。

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
    UIApplicationState state = [application applicationState];



    if (state == UIApplicationStateActive) {
      UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        //localNotification.userInfo = @"Hey";
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.alertBody = self.notiname;
        localNotification.fireDate = [NSDate date];
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
        AudioServicesPlaySystemSound(1104);
 }
}

0 个答案:

没有答案