I am receiving remote notifications via Google Cloud Messages. A message pops up, a badge gets attached to the app item, also the sound works fine. Now I am trying to access additional data but struggle a bit. That's how the message looks like:
Notification received: [gcm.notification.shops: ["548","525"], gcm.message_id: 0:1472546619970126%1dfec10a1dfec10a, gcm.notification.vibrate: 1, aps: {
alert = {
body = "2 neue Gutscheine verf\U00fcgbar";
title = "Neue Gutscheine";
};
badge = 2;
"content-available" = 1;
sound = 1;
}]
How can I now access the shops array? This does not work:
var shops :[String] = userInfo["shops"] as! [String]
I am trying to handle it in the didReceiveRemoteNotification() function.
Changing the element from an array to a string an turning it into an array at the very end did the trick:
if let v = userInfo["gcm.notification.shops"] as? NSString{
let new_vouchers_string = v.componentsSeparatedByString(",")
let new_vouchers = new_vouchers_string.map { Int($0)!}
}