我想使用Azure移动服务和Apache Cordova的Visual Studio工具开始工作。(https://msdn.microsoft.com/en-gb/magazine/dn879353.aspx)
我想用移动服务实现推送通知。我已经创建了一个带有Node后端和TodoItem表的服务,并设置了GCM。
但是,当我尝试注册模板时,出现了404未找到错误:
var GCM_SENDER_ID = 'MY_GCM_ID';
mobileServiceClient = new WindowsAzure.MobileServiceClient(
"MY_URL",
"MY_API_KEY"
);
pushNotification = PushNotification.init({
"android": { "senderID": GCM_SENDER_ID }
});
pushNotification.on('registration', function (data) {
var handle = data.registrationId; //This appears to be set alright
var platform = device.platform; // This is 'Android'
if (platform == 'android' || platform == 'Android') {
var template = '{ "data" : {"message":"$(message)"}}';
mobileServiceClient.push.gcm.registerTemplate(handle, 'myTemplate', template, null);
});
最后一行提示我收到了一个404错误。我正在Google Android模拟器中运行应用。
编辑:我试着使用Postman调用registrations端点:https://myservice.azure-mobile.net/push/registrations?platform=gcm&deviceId=
如果我使用GET方法,响应是[],如果我使用POST方法,会收到404错误。