ios - Catch push notification text on lock screen -


how can push notification text when app not run or in lock screen?

i did try:

func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject], fetchcompletionhandler completionhandler: (uibackgroundfetchresult) -> void) {     println(userinfo)     // or     println("something") } 

but doesn't print me anything. wrong function???

didreceiveremotenotification function called condition.

  1. while app running , app in foreground.(alert not showing)
  2. if app in background , click notification on home screen

if app not run in device didreceiveremotenotification function not called, in case user click notification in home screen, identify app launched notification or not in didfinishlaunchingwithoptions

uilocalnotification *localnotif =[launchoptions objectforkey: uiapplicationlaunchoptionsremotenotificationkey]; 

you userinfo data in localnotif.userinfo

try in swift

 func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {  var userinfo : nsdictionary =launchoptions[uiapplicationlaunchoptionsremotenotificationkey];         print(launchoptions);         return true     } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -