【问题标题】:Push notification not showing when app is in running in cordova应用程序在科尔多瓦运行时未显示推送通知
【发布时间】:2014-11-15 15:50:47
【问题描述】:

我已经在cordova中使用(https://github.com/phonegap-build/PushPlugin)成功实现了推送通知。除了应用程序运行时(即前台)没有显示推送通知外,一切正常工作。这是代码

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;

【问题讨论】:

    标签: javascript android cordova push-notification ionic-framework


    【解决方案1】:
    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;
    

    【讨论】:

      猜你喜欢
      • 2017-09-06
      • 1970-01-01
      • 2018-01-29
      • 2015-11-24
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      相关资源
      最近更新 更多