Onesignal-ios-sdk: access Additional data in func didReceive(_ notification: UNNotification) {

Created on 4 Jan 2017  路  3Comments  路  Source: OneSignal/OneSignal-iOS-SDK

How can I access in
func didReceive(_ notification: UNNotification) {
the additional data from the payload?

Most helpful comment

@appcelerate if you still need it:

guard let customData = notification.request.content.userInfo["custom"] as? Dictionary<String,Any> else { return }
guard let oneSignalAdditionalData = customData["a"]  as? Dictionary<String,String> else { return }

Remember! _Additional data_ is always [String: String]

All 3 comments

@appcelerate You should setup a OSHandleNotificationActionBlock block which will give you a Object where this has been parsed for you. See initWithLaunchOptions for an example of setting one up.

Closing due to inactively. Feel free to reopen if you have more questions on this callback.

@appcelerate if you still need it:

guard let customData = notification.request.content.userInfo["custom"] as? Dictionary<String,Any> else { return }
guard let oneSignalAdditionalData = customData["a"]  as? Dictionary<String,String> else { return }

Remember! _Additional data_ is always [String: String]

Was this page helpful?
0 / 5 - 0 ratings