Swift iOS 10 didReceiveRemoteNotification only pops notification ignores other command -
my intention pretty straight forward:
- receive remote notification
- send local notification user
- update local database new data
tell server data received
func application(_ application: uiapplication, didreceiveremotenotification userinfo: [anyhashable : any], fetchcompletionhandler completionhandler: @escaping (uibackgroundfetchresult) -> void) { // receiption code here nslog("received remotely:: \(userinfo)") let content = unmutablenotificationcontent() content.body = message.body() content.title = message.body() content.subtitle = "new message" content.sound = unnotificationsound.default() content.badge = nsnumber(value:uiapplication.shared.applicationiconbadgenumber+1) let trigger = untimeintervalnotificationtrigger(timeinterval: 1, repeats: false) let request = unnotificationrequest(identifier: message.thread(), content: content, trigger: trigger) let center = unusernotificationcenter.current() center.add(request) dispatchqueue.global(qos: .background).async { [weak self] () -> void in if !(self?.xmppstream?.isconnected())! { let _ = self?.connect() }else{ xmppstream.send(receptionmessage) } }
but happens local notification sent, thats it. other commands executed on app resume.
Comments
Post a Comment