如何处理 iOS 远程消息中的附加数据 GCM

How to handle additional data GCM in iOS remote messages

我正在通过 Google 云消息接收远程通知。弹出一条消息,徽章附加到应用程序项目,声音也正常。现在我正在尝试访问其他数据,但有点困难。这就是消息的样子:

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;
}]

我现在如何访问商店数组?这不起作用:

var shops :[String] = userInfo["shops"] as! [String]

我正在尝试在 didReceiveRemoteNotification() 函数中处理它。

将元素从数组更改为字符串并在最后将其转换为数组就成功了:

 if let v = userInfo["gcm.notification.shops"] as? NSString{
   let new_vouchers_string = v.componentsSeparatedByString(",")
   let new_vouchers = new_vouchers_string.map { Int([=10=])!}
 }