Swift通过通知发送其他数据

时间:2017-02-19 19:58:53

标签: ios swift onesignal

如何在我目前使用Onesignal发送通知的通知中传递其他数据。我不确定我是否使用密钥additionalData发送附加数据。我收到通知但我没有收到额外的数据

//my custom completion handler to retrieve user token


self.getUserInfoCustom(userIdSearching: sendNotifToUser, completion: { (userInfo) in
                // send notif
                if let notif = userInfo?.deviceToken {
                    let value:NSMutableDictionary = [:]
                    value["include_player_ids"] = [notif]
                    value["contents"] = ["en": "Test Message"]
                    let additionalData = ["name":"Pierre"]
                    value["additionalData"] = additionalData
                    OneSignal.postNotification((value as NSDictionary) as! [AnyHashable:Any])
                }
            })

1 个答案:

答案 0 :(得分:0)

不要使用additionalData,只需使用data

即可