Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 离子推送通知_Ionic Framework_Ionic View - Fatal编程技术网

Ionic framework 离子推送通知

Ionic framework 离子推送通知,ionic-framework,ionic-view,Ionic Framework,Ionic View,我已经在我的android应用程序上实现了离子推送通知。推送通知在应用程序未运行(无论是在后台还是未启动)时运行良好,但是,它不会获得在后台运行或根本未启动时有效的状态栏通知(通知栏)或振动 $ionicPlatform.ready(function() { localStorage.myPush = ''; // I use a localStorage variable to persist the token var tokenID = ''; $cordovaP

我已经在我的android应用程序上实现了离子推送通知。推送通知在应用程序未运行(无论是在后台还是未启动)时运行良好,但是,它不会获得在后台运行或根本未启动时有效的状态栏通知(通知栏)或振动

$ionicPlatform.ready(function() {

    localStorage.myPush = ''; // I use a localStorage variable to persist the token
    var tokenID = '';
    $cordovaPushV5.initialize(  // important to initialize with the multidevice structure !!
        {
            android: {
                senderID: "457390407561"
            },
            ios: {
                alert: 'true',
                badge: true,
                sound: 'false',
                clearBadge: true
            },
            windows: {}
        }
    ).then(function (result) {
        $cordovaPushV5.onNotification();
        $cordovaPushV5.onError();
        $cordovaPushV5.register().then(function (resultreg) {
            localStorage.myPush = resultreg;
            console.log(localStorage);
        }, function (err) {
            // handle error
        });
    });

    $rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data){
      // data.message,
      // data.title,
      // data.count,
      // data.sound,
      // data.image,
      // data.additionalData
      console.log("notification received");
      console.log(event);
      console.log(data);
      console.log(data.message);
      console.log(data.title);
      console.log(data.count);
      console.log(data.sound);

      if (data.additionalData.foreground === true) {
        // do something if the app is in foreground while receiving to push - handle in app push handling
        console.log("notification received in foreground");
      }
      else {
       // handle push messages while app is in background or not started
       console.log("notification received in background");
       $state.go('app.orderlist');
      }

    });
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  });
有什么建议吗

提前谢谢。

您可以添加

forceShow: true
如下

$cordovaPushV5.initialize(  // important to initialize with the multidevice structure !!
        {
            android: {
                senderID: "xxxxxxxxx",
                forceShow: true
            },
            ios: {
                alert: 'true',
                badge: true,
                sound: 'false',
                clearBadge: true,
            },
            windows: {}
        }
    )