Firebase + Ionic Framework:聊天通知

时间:2015-04-28 10:14:17

标签: notifications firebase ionic-framework

所以我想知道是否可以使用Firebase和Ionic Framework实现某种通知,我正在使用它来创建应用。我可以只使用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;
} 

它应该将Push notificaiton发送到目标设备,但它什么都不做..

答案:

好的,问题在于以下几行:

 registerNotification.deviceToken = deviceToken;

更改为:

     registerNotification.where= {deviceToken: deviceToken};

1 个答案:

答案 0 :(得分:0)

我对Firebase不确定,但使用Parse很容易理解,我设法让所有内容与ngCordova Push Notifications完美配合。

https://parse.com/products/push
http://ngcordova.com/docs/plugins/pushNotifications/
https://www.parse.com/tutorials/ios-push-notifications

我希望这些帮助。