Removing UILocalNotification from notification tray programmatically

后端 未结 7 1789
再見小時候
再見小時候 2020-12-29 10:29

Is there a way to programmatically remove/dismiss UILocalNotification from Notification Tray. I am able to cancel the notification which removes the notificatio

7条回答
  •  情话喂你
    2020-12-29 10:53

    If the Application is not running, you will be receiving the Local Notification object in the

    -applicationDidFinishLaunchingWithOptions:

    like:

    UILocalNotification *localNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsLocalNotificationKey];
    

    or else you can get it in

    • (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

    Now you can remove it from the Notification Center using

    [[UIApplication sharedApplication] cancelLocalNotification:notificationToCancel];

提交回复
热议问题