【问题标题】:ionic framework FCM plugin离子框架 FCM 插件
【发布时间】:2016-10-17 11:26:16
【问题描述】:

现在我可以通过 firebase 控制台 (firebase) 成功发送所有应用程序的通知。
问题是我无法向特定设备发送通知。

这是我正在运行的代码功能:

.run(function($ionicPlatform) {
   $ionicPlatform.ready(function() {
      FCMPlugin.getToken(
      function(token){
          alert("fire base token :)    :"+token);
      },
      function(err){
          console.log('error retrieving token: ' + err);
      }
  )

});

我得到了令牌,当我使用 firebase 将它发送到特定设备时,它说“令牌无效/”
哪一部分出了问题?
我是不是误会了什么?
我的项目是离子框架标签示例代码。

【问题讨论】:

  • 您是从 Firebase 控制台发送消息吗?
  • 抱歉回答晚了。是的,我正在尝试通过 Firebase 控制台发送到特定设备
  • 很难用给定的细节来判断。您可以尝试验证令牌吗?
  • 如何验证令牌?就格式而言,令牌似乎是正确的。 (我对这个通知过程真的很陌生)
  • 查看步骤here。具体来说,如果要确认注册令牌的有效性,可以通过将“ABC”替换为注册令牌来实现。 (不用担心。我会尽力帮助你)。

标签: ionic-framework firebase notifications firebase-cloud-messaging


【解决方案1】:

使用打击代码

.run(function ($ionicPlatform, $rootScope, $state) {
$ionicPlatform.ready(function() {
    if(window.cordova) {
        FCMPlugin.onNotification(
            function(data){

                if(data.wasTapped){
                   // $state.go('message', {id:data.pageId});
                  // $location.path('app/userList');
                    console.log('onNotification tapped true');
                } else {
                    console.log("xxxxxxxxxxxx"+data.message);
                }
            },
            function(msg){
             // alert("asdf"+msg)
                console.log('onNotification callback successfully registered: ' + msg);
                FCMPlugin.getToken(
                 function(token){
                   //alert(token);
                   window.localStorage.setItem("deviceId",token)
                 },
                 function(err){
                   console.log('error retrieving token: ' + err);
                 }
               )
            },
            function(err){
             // alert("fjkjg"+err)
                console.log('Error registering onNotification callback: ' + err);
            }
        );
    }
});

})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 2016-10-14
    • 2021-02-12
    • 2019-07-25
    • 2016-11-12
    • 2015-05-12
    相关资源
    最近更新 更多