What method is triggered when local notification is dismissed from notification centre of iOS?

◇◆丶佛笑我妖孽 提交于 2019-12-02 23:02:43

问题


I am trying to create an app which fires a local notification and when the notification is tapped, a specific viewcontroller should be opened. I used didReceiveLocalNotification method to display a specific view controller. But that specific view controller is being displayed even when I dismiss the notification from notification centre.

What method is triggered when we dismiss the notification?

Here is the code I used:

func application(application: UIApplication!,didReceiveLocalNotification notification: UILocalNotification)
{
    var root = self.window!.rootViewController as ViewController
    let main: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    var setview = main.instantiateViewControllerWithIdentifier("destination") as tapViewController
    //root.navigationController?.popToViewController(setview, animated: false)
    if application.applicationState == UIApplicationState.Inactive
    {
        root.presentViewController(setview, animated:false , completion: nil)
    }
}

回答1:


As far as I looked for your question's answer on web and apple docs, there is 'NO' such delegate method available which get triggers when a notification is dismissed.

And cancelLocalNotification(notification) is a custom method need to be called by one-self.



来源:https://stackoverflow.com/questions/29096282/what-method-is-triggered-when-local-notification-is-dismissed-from-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!