Cordova Angular应用程序在收到通知时自动关闭

Cordova Angular应用程序在收到通知时自动关闭,angular,cordova,Angular,Cordova,我正在开发cordova angular应用程序,并使用cordova插件fcm插件,但当我发送通知时,我的应用程序自动关闭,我尝试了很多,但没有成功。 请按代码检查: onNotificationCallback函数中的not触发器总是在successCallback中触发 FCMPlugin.onNotification( function(data){ alert("Tapped: " + JSON.stringify(data) ); if(data.wasTa

我正在开发cordova angular应用程序,并使用cordova插件fcm插件,但当我发送通知时,我的应用程序自动关闭,我尝试了很多,但没有成功。 请按代码检查: onNotificationCallback函数中的not触发器总是在successCallback中触发

FCMPlugin.onNotification(
    function(data){ alert("Tapped: " +  JSON.stringify(data) );
        if(data.wasTapped){
            //Notification was received on device tray and tapped by the user.
            alert("Tapped: " +  JSON.stringify(data) );
        }else{
            //Notification was received in foreground. Maybe the user needs to be notified.
            alert("Not tapped: " + JSON.stringify(data) );
        }
    },
    function(msg){
        alert('onNotification callback successfully registered: ' + msg);
        console.log('onNotification callback successfully registered: ' + msg);
    },
    function(err){
        alert('Error registering onNotification callback: ' + err);
        console.log('Error registering onNotification callback: ' + err);
    }
    );  

  $scope.send = function(){
    //FCMPlugin.subscribeToTopic( topic, successCallback(msg), errorCallback(err) );
    //All devices are subscribed automatically to 'all' and 'ios' or 'android' topic respectively.
    //Must match the following regular expression: "[a-zA-Z0-9-_.~%]{1,900}".
    FCMPlugin.subscribeToTopic('all'); //subscribe current user to topic

    var fcm_server_key = "AIzaSyCmu7RXJkSsNJch9MB5ySDUbguyRBeAWm8";

    $http({
      method: "POST",
      dataType: 'jsonp',
      headers: {'Content-Type': 'application/json', 'Authorization': 'key=' + fcm_server_key},
      url: "https://fcm.googleapis.com/fcm/send",
      data: JSON.stringify(
          {
            "notification":{
              "title":" FCM Starter message",  //Any value
              "body": "body of my msg",  //Any value
              "sound": "default", //If you want notification sound
              "click_action": "FCM_PLUGIN_ACTIVITY",  //Must be present for Android
              "icon": "fcm_push_icon"  //White icon Android resource
            },
            "data":{
              "param1":"value1",  //Any data to be retrieved in the notification callback
              "param2": $scope.formData.message
            },
            "to":Globals.token, //Topic or single device
            "priority":"high", //If not set, notification won't be delivered on completely closed iOS app
            "restricted_package_name":"" //Optional. Set for application filtering
          }
        )
    }).success(function(data){

      alert("Success: " + JSON.stringify(data));
    }).error(function(data){
      alert("Error: " + JSON.stringify(data));
    });
  }