ios - How can I print out push notifications when app is in foreground or background? -


i got push notifications work, i'm stuck determining how push views depending on push notification sent user.

in didreceiveremotenotification function, println statement not print when receive push notification despite appearing while app in background.

i print out each remote push notification phone receives can determine how set logic handle it?

func application(application: uiapplication, didreceiveremotenotification userinfo:[nsobject : anyobject]) {     println("recived: \(userinfo)")   } 

try using delegate method:

func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject], fetchcompletionhandler handler: (uibackgroundfetchresult) -> void) {     println("recived: \(userinfo)") } 

as mentioned @ apple docs:

use method process incoming remote notifications app. unlike application:didreceiveremotenotification: method, called when app running in foreground, system calls method when app running in foreground or background. in addition, if enabled remote notifications background mode, system launches app (or wakes suspended state) , puts in background state when remote notification arrives. however, system not automatically launch app if user has force-quit it. in situation, user must relaunch app or restart device before system attempts launch app automatically again.

for more info check link.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -