How to make your push notification Open a certain view controller?

后端 未结 4 749
星月不相逢
星月不相逢 2020-12-09 00:43

I looked on SO but I wasn\'t able to find any question that discusses when you receive a push notification how can you then open a specific view controller. For example if y

4条回答
  •  死守一世寂寞
    2020-12-09 01:29

    Here is the Swift 3 Version with switch/case instead of if/else

        open func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
        switch application.applicationState {
        case .active:
            print("do stuff in case App is active")
        case .background:
            print("do stuff in case App is in background")
        case .inactive:
            print("do stuff in case App is inactive")
        }
    }
    

提交回复
热议问题