I am attempting to retrieve the custom data sent in a push notification.
The custom data is :
[{"test":"01"}]
The pushNotification is recieved as:
[AnyHashable("aps"): { alert = "Hello World!"; sound = default;}, AnyHashable("u"): [{"test":"01"}] , AnyHashable("p"):2Q]
And my push accepted is as follows:
func onPushAccepted(_ pushManager: PushNotificationManager!, withNotification pushNotification: [AnyHashable : Any]!, onStart: Bool) {
print("Push notification accepted: \(pushNotification!)")
if let aps = pushNotification["aps"] as? [String:Any] {
let customData = aps["u"] as! String
print("json String:\(customData)")
}
When I run the code it crashes on line:
let customData = aps["u"] as! String
Any help much appreciated!