PhoneGap和Parse.com推送通知IOS [英] Phonegap and Parse.com Push Notifications IOS
问题描述
所以我想设置一个PhoneGap IOS和Parse.com推送通知应用程序。我使用此插件 https://github.com/mgcrea/cordova-push-notification用苹果注册设备并获取设备令牌。现在我需要将数据保存到我的Parse上的Installition类。问题是当我做一个保存它创建一个新的安装类。
So I am trying to setup a PhoneGap IOS and Parse.com Push notification app. I am using this plugin https://github.com/mgcrea/cordova-push-notification to register the device with apple and get back the device token. Now I need to save that data to the Installition class on my Parse. Problem is when I do a save it creates a new installation class.
var Installation = Parse.Object.extend("Installation");
var installation = new Installation();
installation.save({badge: status.pushBadge, deviceToken: status.deviceToken, deviceType: status.type, installationId: appID}, {
success: function(response){
alert("seccuees " + response);
},
error: function(error){
alert("error " + error.message);
}
});
我也尝试过使用ajax调用rest api和no go ..
I have also tried using a ajax call to the rest api and no go..
$.ajax({
type: 'GET',
headers: {'X-Parse-Application-Id':'miid','X-Parse-Rest-API-Key':'myid'},
url: "https://api.parse.com/1/installations",
data: {"deviceType": "ios", "deviceToken": "01234567890123456789", "channels": [""]},
contentType: "application/json",
success: function(response){
alert("Success " + response);
},
error: function(error){
alert("Error " + error.message);
}
});
推荐答案
不要使用安装类。它将只创建一个新的安装对象。要为推送通知创建Parse安装对象,请使用_Installation。
Dont use "Installation" class. It will just create a new Installation object. To create Parse Installation object for Push notification, use "_Installation". Following is the way to do it.
var installation = new Parse.Object("_Installation");;
installation.save({ channels: ['channelName'], deviceType: "android", installationId: id}, {
success: function(response){
alert("success " + response);
},
error: function(error){
alert("error " + error.message);
}
});
这篇关于PhoneGap和Parse.com推送通知IOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!