0

코드가 (https://github.com/phonegap-build/PushPlugin) 인 푸시 알림을 성공적으로 구현했습니다. 앱이 실행 중일 때 푸시 알림 (예 : 포 그라운드)이 표시되지 않는 것을 제외하고는 모두 올바르게 작동합니다. 코드앱이 cordova에서 실행 중일 때 알림이 표시되지 않음

case 'message': 
     // if this flag is set, this notification happened while we were in the foreground. 
     // you might want to play a sound to get the user's attention, throw up a dialog, etc. 
     if (e.foreground) 
     { 
      // if this flag is set, this notification happened while we were in the foreground. 
      //this is not working 
      if(e.foreground){    
       var myMedia = new Media("/assets/www/img/beep.mp3");    
       my_media.play(); 
      }else{ 
       // otherwise we were launched because the user touched a notification in the notification tray. 
      } 
    break; 

답변

0
case 'message': 
     // if this flag is set, this notification happened while we were in the foreground. 
     // you might want to play a sound to get the user's attention, throw up a dialog, etc. 
     if (e.foreground) { 
      //when you are running the app, you get the alert 
      alert(e.payload.message); 


     } 
     else { 
       //do something for the case where user is not using the app. 
        if (e.coldstart) 
        console.log('--COLDSTART NOTIFICATION--' + ''); 
       else 
        console.log('--BACKGROUND NOTIFICATION--' + ''); 
       $window.location.href = ('#/bucket/notification'); 
      } 
     break; 
관련 문제