【发布时间】:2015-04-29 00:36:18
【问题描述】:
所以我想知道是否可以使用我用来创建应用程序的 Firebase 和 Ionic 框架来实现某种通知。我可以只坚持使用 Firebase,还是需要一些其他服务,例如 Parse?
谢谢!
编辑:
我让 Parse 工作了 - 太棒了。唯一对我不起作用的是以下代码:
function sendNotification(deviceToken, content){
console.log('targetDevice is: ' + deviceToken);
console.log('content is:' + content);
var notificationEndpoint = AY_Parse.parseEndpoint + "/1/push";
var headers = {
'Content-Type': 'application/json',
'X-Parse-Application-Id': AY_Parse.parseApplicationId,
'X-Parse-REST-API-Key': AY_Parse.parseRestApiKey
};
var pushNotification = $resource(notificationEndpoint, {},
{
'save': {
method: 'PUT',
headers: headers
}
});
var registerNotification = new pushNotification();
registerNotification.deviceToken = deviceToken;
registerNotification.data = {alert: content};
console.log(registerNotification);
console.log(angular.toJson(registerNotification));
return registerNotification.$save;
}
它应该向目标设备发送推送通知,但是它什么也没做..
答案:
好的,问题出在以下行:
registerNotification.deviceToken = deviceToken;
改为:
registerNotification.where= {deviceToken: deviceToken};
【问题讨论】:
标签: notifications firebase ionic-framework