首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >推送通知,未显示应用程序何时打开,pushwoosh Phonegap

推送通知,未显示应用程序何时打开,pushwoosh Phonegap
EN

Stack Overflow用户
提问于 2015-02-11 11:31:45
回答 1查看 1.9K关注 0票数 0

我使用Pushwoosh在Phonegap中发送通知,但是如果我在应用程序中,通知不会同时显示在Android和iOS的情况下。

我该怎么解决这个问题?

我已经通过了几个链接,但没有能够弄清楚这一点。

代码语言:javascript
复制
   function initPushwoosh()
{

    var pushNotification = window.plugins.pushNotification;

    if (device.platform == "Android")
    {

        //set push notifications handler
        document.addEventListener('push-notification', function(event) {
            var title = event.notification.title;
            var userData = event.notification.userdata;

            if (typeof (userData) != "undefined") {
                console.warn('user data: ' + JSON.stringify(userData));
            }


        });

        //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
        pushNotification.onDeviceReady({projectid: "", appid: ""});


        //register for pushes
        pushNotification.registerDevice(
                function(status) {
                    var pushToken = status;

                    localStorage.setItem("deviceid", pushToken);

                    console.warn('push token: ' + pushToken);
                },
                function(status) {
                    console.warn(JSON.stringify(['failed to register ', status]));
                }
        );



    }
    else if (device.platform == "iOS")
    {
        //set push notification callback before we initialize the plugin
        document.addEventListener('push-notification', function(event) {
            //get the notification payload
            var notification = event.notification;
            navigator.notification.alert(notification.aps.alert);


            //clear the app badge
            pushNotification.setApplicationIconBadgeNumber(0);
        });

        //initialize the plugin
        pushNotification.onDeviceReady({pw_appid: ""});

        //register for pushes
        pushNotification.registerDevice(
                function(status) {
                    var deviceToken = status['deviceToken'];
                    localStorage.setItem("deviceid", deviceToken);




                },
                function(status) {
                    console.warn('failed to register : ' + JSON.stringify(status));

                }
        );


        //reset badges on app start
        pushNotification.setApplicationIconBadgeNumber(0);
    }
}



function init()
{

    document.addEventListener("deviceready", initPushwoosh, true);
    // document.addEventListener("backbutton", onBackKeyDown, false);
    // Cordova is ready to be used!
}
EN

回答 1

Stack Overflow用户

发布于 2017-01-14 14:53:04

使用武力显示

代码语言:javascript
复制
var push = PushNotification.init(
     { "android": {"senderID": "533867441597", "forceShow": "true"
             },
  "ios": {"alert": "true", "badge": "true", "sound": "true"
         } 

});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28453269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档