2016-09-01 3 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를 넣어
관련 문제