【问题标题】:Cordova FCM plugin handle background notification dataCordova FCM 插件处理后台通知数据
【发布时间】:2017-05-08 11:11:30
【问题描述】:

我正在使用以下代码使用 firebase 在我的 ionic 应用程序上接收数据,当应用程序处于后台时,我得到 data.wastapped = true 现在我需要将数据传递给我的主控制器,请帮助我实现这一目标

 FCMPlugin.onNotification(
                        function(data){
                            if(data.wasTapped){
    alert(JSON.stringify(data);
    // need to pass this data to my app controller

                                tapped by the user.
                                alert( JSON.stringify(data) );
                            }else{

                                alert( JSON.stringify(data) );
                            }
                        },
                        function(msg){
                            alert('onNotification callback successfully registered: ' + msg);
                        },
                        function(err){
                            alert('Error registering onNotification callback: ' + err);
                        }

【问题讨论】:

    标签: ionic-framework cordova-plugin-fcm


    【解决方案1】:

    @拉姆, 试试下面这个函数

    var scope = angular.element(document.getElementById('mainbody')).scope();   
    scope.$apply(function(){
               //show popup regarding alert         
                scope.showdatas(data);
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-15
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      相关资源
      最近更新 更多