locked
How to use Azure Notification REST API with Google Cloud Messaging RRS feed

  • Question

  • We are implementing an application using Unity 3d and we are consuming the Azure Push Notification REST API.
    But there are a couple of issues and questions on how to successfully send and receive the message.

    For testing we are using Advanced Rest client extension for chrome.
    We are able to create the registration by using the native template ( check https://msdn.microsoft.com/en-us/library/azure/dn223265.aspx )

        <?xml version="1.0" encoding="utf-8"?>
        <entry xmlns="http://www.w3.org/2005/Atom">
            <content type="application/xml">
                <GcmRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
                    <Tags></Tags>
                    <GcmRegistrationId>Some Id from somewhere</GcmRegistrationId> 
                </GcmRegistrationDescription>
            </content>
        </entry>

    So far we are sending the request with empty Tags, and we are not sure what the GcmRegistration should be, the weird thing is that no matter what we send there we get a valid response.

        <entry a:etag="W/"1"">
          <id>https://cloudservicechat-ns.servicebus.windows.net/cloudservicechat/registrations/8760279628548469956-1956153846630646542-1?api-version=2015-01</id>
          <title type="text">8760279628548469956-1956153846630646542-1</title>
          <published>2016-06-01T15:15:16Z</published>
          <updated>2016-06-01T15:15:16Z</updated>
          <link rel="self" href="https://cloudservicechat-ns.servicebus.windows.net/cloudservicechat/registrations/8760279628548469956-1956153846630646542-1?api-version=2015-01" />
          <content type="application/xml">
            <GcmRegistrationDescription>
            <ETag>1</ETag>
            <ExpirationTime>2016-08-30T15:15:16.215Z</ExpirationTime>
            <RegistrationId>8760279628548469956-1956153846630646542-1</RegistrationId>
            <GcmRegistrationId>Some Id from somewhere</GcmRegistrationId>
            </GcmRegistrationDescription>
          </content>
        </entry>

    Now we are trying to send the notification (https://msdn.microsoft.com/en-us/library/azure/dn223273.aspx) but we are not sure of the correct payload to use from azure when using GCM
    According to the documentation in GCM
    the payload would be something like this

          {
            "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
            "notification" : {
              "body" : "great match!",
              "title" : "Portugal vs. Denmark",
              "icon" : "myicon"
            }
          }

    However no matter what we do, we always get an Unauthorized response.

    Also tried to use the registration using templates, but we are not sure what we should add in <BodyTemplate><![CDATA[ {BodyTemplate}]]></BodyTemplate> (check https://msdn.microsoft.com/en-us/library/azure/dn223265.aspx)

    So the questions would be
    * Where we can get the GcmRegistrationId from?
    * How we should replace format the {BodyTemplate}
    * What would be a valid notification payload to use using Azure Test Send

    Thanks for the help

    Eduardo Fonseca

    Wednesday, June 1, 2016 4:09 PM

All replies

  • Hi Eduardo,

    https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-android-get-started/ might be helpful to read through for some concepts and things like GcmRegistrationId. You can find the template formats at https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-templates/ or https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-aspnet-cross-platform-notify-users/. You can find the sample for a test payload in the latter tutorial as well. Hope that helps.

    Mimi

    • Proposed as answer by Mimi Xu Wednesday, June 1, 2016 9:36 PM
    Wednesday, June 1, 2016 9:36 PM