ios - processing push data when app closed, app open and app in background -
i have following fund in app delegate:
func application(_ application: uiapplication, didreceiveremotenotification data: [anyhashable : any]) { // print notification payload data print("push notification received: \(data)") let dictpayload = data nsdictionary if let data = dictpayload.value(forkey: "aps") as? nsdictionary { let link = data.value(forkey: "link") as? string print("link: \(link!)") userdefaults.standard.set(link, forkey: "link_from_push") userdefaults.standard.synchronize() }
basically, push notification contains data link in app. when user opens app, need log user on automatically, bunch of stuff , open link.
my code works fine when app open. receive push, extract link no problem.
on other hand when app closed or in background, didreceiveremotenotification not being called, , guessing isn't being called because userdefaults.standard forkey: "link_from_push") not being set.
how can set value of link userdefaults.standard forkey:"link_from_push" when app in background or closed. there method need use instead of didreceiveremotenotification
this not duplicate since answer in question: didreceiveremotenotification not called , ios 10 addresses obj c , not swift, , answer given swift did not work.
please help
thank you
Comments
Post a Comment