CrossGeeks / PushNotificationPlugin

Push Notification Plugin for Xamarin iOS and Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting original Payload and Custom Attributes

hanchhanch opened this issue · comments

Hi,
How can I view custom attributes sent within the payload?
Also, is it possible to see the actual payload in the OnNotificationOpened handler? There are only some platform parameters there in the PushNotificationResponseEventArg argument

Thanks

Hello, did you get an answer to your second question : is it possible to see the actual payload in the OnNotificationOpened handler?

yes.
To send the push use this json:

{
  "GCM":
  {  
    "notification":
    {
      "title":"asdfasda",
      "body":"adfadsf"
    },
    "data":
    {
      "custom-data-key":"custom-value"
     }
  },
  "APNS":
  {  
    "aps":
    {
      "title":"asdfasda",
      "body":"adfadsf"
    },
    "data":
    {
      "acmecustom-data-key":"custom-value"
     }
  }

}
   

For Apple Push Notification, note that the custom keys need to be prefixed with 'acme'
The following handler will have the custom keys in the 'p' argument

CrossPushNotification.Current.OnNotificationOpened += (s, p) =>
            {
                    Utils.MiscUtils.HandleNotification(s, p.Data);
            };