I'm creating a cordova project and use azure mobile app + notification hub service. In the cordova project, I add "cordova-plugin-ms-azure-mobile-apps" and "phonegap-plugin-push" plugins, but when run project I get an error:
Failed to load resource: the server responded with a status of 404 - Cannot GET /push/installations/xxxxx(it's a guid string)
Setup details:
phonegap-plugin-push : version="1.7.2" cordova-plugin-ms-azure-mobile-apps : version="2.0.0-beta5" dev tool : visual studio 2015
var azureClient = new WindowsAzure.MobileServiceClient('http://xxxxxx.azurewebsites.net');
//PushNotification.
var push = PushNotification.init({
android: {
senderID: "xxx895803xxxx"
},
ios: {
alert: "true",
badge: "true",
sound: "true",
},
windows: {}
});
push.on('registration', function (data) {
azureClient.push.register('gcm', data.registrationId);
});
push.on('notification', function (data, d2) {
alert('Push Received: ' + data.message);
});
WindowsAzure.MobileServiceClient
is a cordova-plugin-ms-azure-mobile-apps
plugin that connect azure mobile apps and azureClient.push.register
function will call executeRequest
function in MobileServices.Cordova.js
(cordova-plugin-ms-azure-mobile-apps
plugin)
function executeRequest(client, method, pushChannel, content, installationId, callback) {
Validate.isString(pushChannel, 'pushChannel');
Validate.notNullOrEmpty(pushChannel, 'pushChannel');
var headers = { 'If-Modified-Since': 'Mon, 27 Mar 1972 00:00:00 GMT' };
headers[constants.apiVersionHeaderName] = constants.apiVersion;
client._request(
method,
'push/installations/' + encodeURIComponent(installationId),
content,
null,
headers,
callback
);
}