I am using Microsoft azure notification hub for push notification in android. I am able to send notification through nodejs server code. Device get notification from nodejs server.
Problem :- but when i use notification hub it the notification never comes through to the device even though the Notification Hub returns a success code.
Procedure I follow for notification hub.
Step -1 :- Register gcmTokenId to notification hub which i got from my device at a first time registration.
notificationHubService.gcm.createNativeRegistration(gcmToken, tags, function(error){
if(error)
{
res.type('application/json'); // set content-type
res.send(error); // send text response
}
else
{
res.type('application/json'); // set content-type
res.send('Registered Successfully!'); // send text response
}
});
Here are the registration details:-
{
ETag: "1"
ExpirationTime: "2014-09-08T06:33:55.906Z"
RegistrationId: "286469132885875691584-1648906343295271447-3"
Tags: "raj"
GcmRegistrationId: "APA91bF6E2U4*********"
_: {
ContentRootElement: "GcmRegistrationDescription"
id: "id"
title: "2864691328694691584-1648906343295271447-3"
published: "2014-06-10T07:04:30Z"
updated: "2014-06-10T07:04:30Z"
link: ""
}-
}
Step -2 :- Send Notification to hub using following function.
notificationHubService.gcm.send(
null,
{
data: { message: 'Here is a message' }
},
function (error,response) {
if (!error) {
//message send successfully
res.type('application/json'); // set content-type
res.send(response);
}
});
Following are the response code i got from notification hub.
{
isSuccessful: true
statusCode: 201
body: ""
headers: {
transfer-encoding: "chunked"
content-type: "application/xml; charset=utf-8"
server: "Microsoft-HTTPAPI/2.0"
date: "Tue, 10 Jun 2014 07:07:32 GMT"
}-
}
Settings i did in notification hub:
- I add google api key in "google cloud messaging settings".
Please guide me to solve this issue.