push notification - Get userInfo(payload) from PushNotification while app in background -
i have searched , read lot, can't find answer indeed. have known how userinfo(payload) pushnotification while app in foreground or while app launching when user tapped on notification or app icon. still can't find how userinfo(payload) pushnotification while app in background. possible?
now receive notification. , when app in background , receive notification, want track notification received add +1 badge.
i have been trying use method:
func application(_ application: uiapplication, didreceiveremotenotification userinfo: [anyhashable: any], fetchcompletionhandler completionhandler: @escaping (uibackgroundfetchresult) -> void) { if application.applicationstate == .inactive { nslog("inactive") print("%@", userinfo) completionhandler(.newdata) } else if application.applicationstate == .active { nslog("active") print("%@", userinfo) completionhandler(.newdata) } else { nslog("background") print("%@", userinfo) completionhandler(.newdata) } }
and seems ok, last else
block never executed, while above 2 works perfectly
any appreciated!
Comments
Post a Comment