2016-09-01 15 views
0

アプリが強制終了されてもFCMコンソールから送信された通知を受信して​​います。 は、ここに私のクライアントコードです:アプリが強制終了されたときにFCMデータが受信されない

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

問題が戻って受信されない通知呼び出しです。ログデータが表示されます。

View not ready. SAVED NOTIFICATION: javascript:FCMPlugin.onNotificationReceived() 

答えて

0

// Ionic Starter App 

angular.module('starter', ['ionic', 'starter.controllers', 'ngCordovaOauth']) 

.run(function ($ionicPlatform) { 
$ionicPlatform.ready(function() { 
    // 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(); 
    } 

    try{ 
    FCMPlugin.onNotification(
     function(data){ 
     console.log('DATA ==>: '+data); 
     if(data.wasTapped){ 
      //Notification was received on device tray and tapped by the user.  
      console.log('01'); 
      console.log( JSON.stringify(data) ); 
     }else{ 
      //Notification was received in foreground. Maybe the user needs to be notified.  
      console.log('02'); 
      //alert( JSON.stringify(data)); 
     } 
     }, 
     function(msg){ 
      console.log('onNotification callback successfully registered: ' + msg); 
     }, 
     function(err){ 
     console.log('Error registering onNotification callback: ' + err); 
     } 
    ); 
    }catch(e) 
    { 
    console.log('in login'+e) 
    } 
}); 
}) 
にFCMPluginを入れてみてください
関連する問題