locked
Cordova + NotificationHub.js and template registration issue RRS feed

  • Question

  • Hi, I'm building push messaging functions on my AngularJS app with Ionic.

    I use this js lib https://github.com/Azure/mobile-services-samples/blob/master/TodoListNotifications/phonegap/www/js/NotificationHub.js ( the only that I found and the REST API documentation for JS is not good ).


    If I use the template registration to Notifiction Hub , like your code, I'm not able to receive notifications. I'm always registered on hub and GCM.

    // Create the integrated Notification Hub client.
                            var hub = new NotificationHub(mobileClient);

    // Template registration.
                            var template = "{ \"data\" : {\"message\":\"$(message)\"}}";
    //Register for notifications.
     // (gcmRegId, ["tag1","tag2"], templateName, templateBody)
     hub.gcm.register(e.regid, null, "myTemplate", template).done(function () {

    Instead, to receive the notifications, I need to remove template and call: hub.gcm.register(e.regid).done(function () {

    Why?


    Best Regards Biagio Paruolo Italy

    Tuesday, January 13, 2015 2:08 PM

All replies

  • Are you sending the notification from the backend as a template notification? Notice that the service part of that sample calls the generic send() method. I suspect that you are calling the GCM-specific push.gcm.send() method, which requires the native registration that you are having to do to make it work.  

    Please visit my blog

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, March 10, 2015 4:56 PM
  • I push message from a small C# console code which I send message ( later, I'll write the code ). I found a lot documentations on that but it is a lots fragmented and sparse and not a lot on JS and REST. Which is the better and last good documentation? 

    Best Regards Biagio Paruolo Italy

    Wednesday, March 11, 2015 9:55 AM
  • We don't really have good documentation for Notification Hubs from a JavaScript client using REST. I will make sure that we have this content on the list. If you were planning to also use Mobile Services (since you get a free notification hub with each mobile service), then you don't have to use REST, as I show in my MSDN Magazine article.


    Please visit my blog

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, March 13, 2015 12:36 AM
  • This is my small demo code to push a message to the Android devices with notification hub.

    I don't want to use Mobile Services.

     private static async Task<NotificationOutcomeState> SendNotificationAsync()

            {

                string title = "This is a demo";

                string tag = "news";

                string androidNotification = "{ \"data\" : {\"message\":\"Ciao\",\"title\":\"Ciao\"}}";

        NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("Endpoint=sb://xyzyks.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=eiurueiueiruierieuuer", "megahub");

        var outcome = await hub.SendGcmNativeNotificationAsync(androidNotification);

      //  hubClient.SendGcmNativeNotificationAsync("{ \"data\" : {\"msg\":\"Hello from Windows Azure!\"}}", "xxxapp");

        Console.WriteLine(outcome.Success > 0 ? true : false);

        return outcome.State;

        }


    Best Regards Biagio Paruolo Italy


    Friday, March 13, 2015 6:49 AM
  • This code sends a native push notification to clients registered for native GCM notifications.

    Did you want template notifications?


    Please visit my blog

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, March 19, 2015 6:21 PM
  • This code sends a native push notification to clients registered for native GCM notifications.

    Did you want template notifications?


    Please visit my blog

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Hi,

    yes, I wish to sent notifications with templates. But how to?

    Thx.


    Best Regards Biagio Paruolo Italy

    Friday, March 20, 2015 8:52 AM
  • Any suggestions?

    Best Regards Biagio Paruolo Italy

    Tuesday, April 7, 2015 12:34 PM