How to Open a Specific View Controller On didReceiveRemoteNotification when application is in back ground

前端 未结 3 1801
眼角桃花
眼角桃花 2021-02-10 21:00

I am implementing a alarm where i am getting pushNotification from server, i am receiving perfect push notification and it is working fine in foreground mode but when applicatio

3条回答
  •  醉话见心
    2021-02-10 21:30

    If you app is suspended check the UIApplicationLaunchOptionsRemoteNotificationKey in the dictionary from application:didFinishLaunchingWithOptions

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        ...
    
        // Check if launched from notification
        if let userInfo = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? [String: AnyObject] {
    
            // handle your notification like in application:didReceiveRemoteNotificatioUserInfo:
        }
        ...
    }
    

提交回复
热议问题