2
votes

I am aware that this question is mostly a duplicate of tag registration ANH but there is no specific answer and that's why I am putting it again.

I am working on a Cordova app and using this Azure Mobile Services plugin (https://github.com/Azure/azure-mobile-apps-cordova-client) to register for Push Notifications. I get a successful response from PNS (gcm and apns), and the call to register (registration event) with Notification hub also returns a successful response below. I also get the notifications on the device (both on IOS and Android) when I send the notifications using the 'Test Send' utility from Azure notification hub without specifying tags, but no notifications are received when I try to send notifications using Tags. Is there any other way to register tags?

client.push.register('gcm', handle, {
      mytemplate: { body: { data: { message: "{$(messageParam)}" } },
                 tags: [tag}                          
  }).then(function(data){
        alert("success");
    },function(error){
        alert(error);
    });} else if (device.platform === 'iOS') {
  // Register for notifications.            
  client.push.register('apns', handle, {
      mytemplate: { body: { aps: { alert: "{$(messageParam)}" } },
                  tags: [tag]}                           
  }).then(function(data){
        alert("success");
    },function(error){
        alert(error);
    });} 
1
What's wrong with the answer on the linked question? You need to register tags via your server backend, not directly from the client.Eric Hedstrom
currently, I don't have code for register tags via server backend so is that mean I can't test push notification for particular users? Is there any other way to test it?chotya
@EricHedstrom .chotya
I'm facing the same problem. I tried another plugin as well github.com/derek82511/cordova-azure-notification-hubs and it is not working with Tag. I raised question as well github.com/derek82511/cordova-azure-notification-hubs/issues/11niren

1 Answers

0
votes

If you are using the plugin specified, then you DO have code for the backend. Tags can only be registered in the backend - not the frontend (well, unless you send the tags in the request and then read that request in the backend to do the same request - but that's still the backend doing the registration).

At this point. I'd recommend not using Azure Mobile Apps for this functionality. Create an Azure Function API that does the registration for you, then use that to register for push. Future versions of Azure Mobile Apps are not going to include ANH functionality.