3

I have a payload from Firebase for push notifications of type:

{
 "notification": {
 "title": "myTitle",
 "body": "text",
 "sound": "default",
 "show_in_foreground": true
},
"data": {
  "info": {
     "event": "my_event",
     "order_id": "myOrder"
  }
 }
}

I want to get value by key 'event'. But I discovered that the dictionary:

"info": {
 "event": "my_event",
 "order_id": "myOrder"
}

is seen by the system as String, e.g.:

"info": "{
 "event": "my_event",
 "order_id": "myOrder"
}"

And to get the value for "event" I have to manually transform it from String to NSDictionary.

What I get in the console when this push arrives:

[   
    AnyHashable("info"): {
    "event":"my_event",
    "order_id":"myOrder"
  }, 

   AnyHashable("gcm.notification.show_in_foreground"): true,
   AnyHashable("gcm.message_id"): ... , 
   AnyHashable("aps"): {

        alert =     {
            body = "myTitle";
            title = "text";
        };
        sound = default;
}, 

AnyHashable("google.c.a.e"): 1

]

Have anyone seen it before? Is it Firebase bug and if not, what am I doing wrong?

joliejuly
  • 2,127
  • 1
  • 21
  • 24

0 Answers0