我正在创建一个cordova项目并使用azure移动应用+通知中心服务。 在科尔多瓦项目中,我添加了“科尔多瓦 - 插件-MS-Azure的移动应用程序”和“PhoneGap的-插件推”插件,但跑项目时,我得到一个错误:cordova azure移动应用和通知中心服务
Failed to load resource: the server responded with a status of 404 - Cannot GET /push/installations/xxxxx(it's a guid string)
设置的详细信息:
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
是一个cordova-plugin-ms-azure-mobile-apps
插件连接蔚蓝的移动应用和azureClient.push.register
功能将调用MobileServices.Cordova.js
(cordova-plugin-ms-azure-mobile-apps
插件)executeRequest
功能
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
);
}
谢谢,但我的情况只在移动应用程序和通知中心,我检查了科尔多瓦白名单配置,是currect。 – Ian
您能解释一下“什么时候运行项目”是什么意思吗?你在什么时候收到错误信息?构建还是运行时?如果后者,那么你能粘贴失败的代码块吗? –
嗨, 获取运行时错误(调试模式),发布项目到设备并使用模拟器。 – Ian