【发布时间】:2016-11-08 00:35:04
【问题描述】:
我正在创建一个 cordova 项目并使用 azure 移动应用 + 通知中心服务。 在 cordova 项目中,我添加了“cordova-plugin-ms-azure-mobile-apps”和“phonegap-plugin-push”插件,但是在运行项目时出现错误:
加载资源失败:服务器响应状态为 404 - 无法获取 /push/installations/xxxxx(这是一个 guid 字符串)
设置详情:
phonegap-plugin-push : version="1.7.2" cordova-plugin-ms-azure-mobile-apps : 版本="2.0.0-beta5" 开发工具: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 是一个cordova-plugin-ms-azure-mobile-apps 插件,用于连接Azure 移动应用,azureClient.push.register 函数将调用MobileServices.Cordova.js 中的executeRequest 函数(cordova-plugin-ms-azure-mobile-apps 插件)
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
);
}
【问题讨论】:
标签: cordova cordova-plugins azure-mobile-services visual-studio-cordova azure-notificationhub