urbanairship / urbanairship-xamarin

Urban Airship Xamarin Libraries
https://docs.urbanairship.com/platform/xamarin/
Apache License 2.0
9 stars 5 forks source link

No way to access custom keys? #53

Closed bhazen closed 7 years ago

bhazen commented 7 years ago

In the Android portion of a Xamarin forms project I'm overriding the OnNotificationOpened event like so:

public class NotificationReceiver : AirshipReceiver
{
    protected override bool OnNotificationOpened(Context androidContext, NotificationInfo notificationInfo)
    {
        var notificationId = notificationInfo.NotificationId;
        var alert = notificationInfo.Message.Alert;
        var title = notificationInfo.Message.Title;

        return true;
    }
}

In the messages I'm sending I'm including some additional data as custom keys. I expected to find a property for those on the notificationInfo.Message object, but I don't see the custom keys anywhere. Have I just missed where that data is passed or is there currently not a way to access custom keys from the message?

rlepinski commented 7 years ago

@bhazen You can access the original push bundle with notificationInfo.Message.PushBundle - http://docs.urbanairship.com/reference/libraries/android/latest/reference/com/urbanairship/push/PushMessage.html#getPushBundle()

bhazen commented 7 years ago

Thanks, @rlepinski! That was what I needed. Was able to do: var desiredValue = notificationInfo.Message.PushBundle.GetString("key");