ios - How can I handle FCM when my app is not running? -


i can receive fcm when app active or background.

but can't receive when not running.

how can receive fcm when application state not running?

in didfinishlaunchingwithoptions.there parameter launchoptions contains push notification.store data , handle in firstviewcontroller open.i did writing these lines in appdelegate used swiftyjson , take userpush in singleton class 1:

  guard let pushnotification = launchoptions? [uiapplicationlaunchoptionskey.remotenotification]  else { return true }     print(pushnotification)     let data = json(pushnotification)      userdatasingleton.sharedinstance.notificationdata = data     userdatasingleton.sharedinstance.userpush = 1 

now in splashviewcontroller did:

  override func viewdidappear(_ animated: bool) {     super.viewdidappear(true)      if (userdatasingleton.sharedinstance.userpush == 1){          userdatasingleton.sharedinstance.userpush = 0         let appdelegate = uiapplication.shared.delegate as! appdelegate          appdelegate.handlepushnavigation(userinfo: userdatasingleton.sharedinstance.notificationdata!)      }     else{      }  } 

handlepushnotification func have written 3 cases in appdelegate:

//mark: - handle push notification methods  extension appdelegate{  func handlepush(userinfo : json){      handlepushnavigation(userinfo: userinfo ) }  func handlepushnavigation(userinfo :  json){      let storybard = uistoryboard(name: "main", bundle: nil)      switch userinfo["type"].intvalue {     case 1:          guard let vc = storybard.instantiateviewcontroller(withidentifier: "chatviewcontroller") as? chatviewcontroller else{return}          navigatetovc(vc: vc)      default:break      }  }  func navigatetovc(vc:uiviewcontroller){      ez.topmostvc?.presentvc(vc)  } 

}


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -