0
votes

We are trying to send push notification dynamically to all registered devices (android) using azure push notification. when we are trying to register the device using device token received from flutter mobile app. it is not getting registered.

For reference: https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-nodejs-push-notification-tutorial

In the above documentation, there is no step to register device using their device token to notification hub. So tried to check on some tech forums and got a sample way to proceed on registering device. Code is below for reference.

    notificationHubService.gcm.createTemplateRegistration(
'replacing device token',
'tag', {
'aps': {
'alert': '$(message)',
'badge': '#(count)',
'sound': 'default'
}
},
function (e, r) {
if (e) {
console.log(e);
} else {
console.log({
id: r.RegistrationId,
deviceToken: r.DeviceToken,
expires: r.ExpirationTime
});
}
}
);

Response

{ id: '1294571364808236565-5460521645299605787-1', deviceToken: undefined, expires: '9999-12-31T23:59:59.999' }

device token is always returning as undefined.

1

1 Answers

0
votes

Please refer to this sample of how to use the Azure-SB SDK here.

Using this example, you can set the GCM_REGISTRATION_ID which is the device token from the Android device such as you would get from here.

This has the usage of GCM/Firebase here in registering, which is using the REST-API method of create registration under the covers: Create a registration | Microsoft Docs