Calling didReceiveRemoteNotification when app is launching for the first time

后端 未结 2 1876
后悔当初
后悔当初 2021-01-31 18:27

I have implemented my didReceiveRemoteNotification method. It works and displays a view controller with the notification data which is passed through. This only works when the a

2条回答
  •  广开言路
    2021-01-31 19:06

    Swift Code

    let remoteNotif: AnyObject? = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey]
    
                //Accept push notification when app is not open
                if ((remoteNotif) != nil) {
    
                    self.handleRemoteNotification(remoteNotif!)
                }
    
    
    func handleRemoteNotification(remoteNotif: AnyObject?){
    //handle your notification here
    }
    

    @Eran thanks :)

提交回复
热议问题