【问题标题】:Firebase + Ionic Framework: Chat notificationsFirebase + Ionic Framework:聊天通知
【发布时间】: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


    【解决方案1】:

    我不确定 Firebase,但使用 Parse 很容易理解和理解,我设法通过 ngCordova 推送通知让一切工作完美。

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

    我希望这些帮助。

    【讨论】:

    • 非常感谢您的回答!你能告诉我你是如何处理 Peer 2 Peer 通知发送的吗?还是您只是将数据发送到 Parse 服务器,其中包含接收者 tokenID 和消息?
    • 我也在 Github 上找到了这个,可能会有所帮助。 github.com/arun0009/ionicapp
    • 太好了!非常感谢!
    • 绝对没问题! @uksz
    • 嘿亚当,所以我将设备令牌存储到我的 Firebase 帐户中,但是,我真的不知道如何将设备注册到 Parse 帐户。你能给我这方面的教程吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    • 2021-09-30
    • 1970-01-01
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 2016-10-23
    相关资源
    最近更新 更多