phonegap pushwoosh插件registerDevice回调函数永远不会在android上激活

 米五仔8 发布于 2023-01-14 15:23
  • php
  • 我正在尝试使用Pushwoosh推送通知phonegap构建插件,但registerDevice回调永远不会在我的Android设备上触发,但initPushwoosh功能会触发,因为我在下面的代码中看到来自警报("initPushwoosh")的警报

    下面是我的config.xml

    
    
    
    
    
        Push notification
    
        
            Camera example app.
        
    
        
            PhoneGap Team
        
    
         
    
        
    
         
    
         
    
    

    这是我的index.js,我只是将项目ID和appid更改为XXXX,这样我就不会错误地透露太多.

    var app = {
        // Application Constructor
        initialize: function() {
            this.bindEvents();
        },
        // Bind Event Listeners
        //
        // Bind any events that are required on startup. Common events are:
        // 'load', 'deviceready', 'offline', and 'online'.
        bindEvents: function() {
            document.addEventListener('deviceready', this.onDeviceReady, false);
        },
        // deviceready Event Handler
        //
        // The scope of 'this' is the event. In order to call the 'receivedEvent'
        // function, we must explicity call 'app.receivedEvent(...);'
        onDeviceReady: function() {
            alert("onDeviceReady" );
            app.initPushwoosh();
            app.receivedEvent('deviceready');
    
        },
    
        initPushwoosh: function() {
            alert("initPushwoosh" );
                var pushNotification = window.plugins.pushNotification;
                pushNotification.registerDevice(
                { projectid: "XXX-XXX-XXXX 3", appid : "XXXXX-XXXXX" },
                    function(status) {
                        var pushToken = status;
                        alert('push token: ' + pushToken);
                    },
                    function(status) {
                        alert(JSON.stringify(['failed to register ', status]));
                });
                document.addEventListener('push-notification', function(event) {            
                    var title = event.notification.title;
                     var userData = event.notification.userdata;
                    if (typeof(userData) != "undefined") {
                       alert('user data: ' + JSON.stringify(userData));
                    }    
                    navigator.notification.alert(title);
                });
        },
        // Update DOM on a Received Event
        receivedEvent: function(id) {
            var parentElement = document.getElementById(id);
            var listeningElement = parentElement.querySelector('.listening');
            var receivedElement = parentElement.querySelector('.received');
    
            listeningElement.setAttribute('style', 'display:none;');
            receivedElement.setAttribute('style', 'display:block;');
    
            console.log('Received Event: ' + id);
        },
    
        takePicture: function() {
          navigator.camera.getPicture( function( imageURI ) {
            alert( imageURI );
          },
          function( message ) {
            alert( message );
          },
          {
            quality: 50,
            destinationType: Camera.DestinationType.FILE_URI
          });
        }
    };
    

    任何帮助将不胜感激...谢谢!

    撰写答案
    今天,你开发时遇到什么问题呢?
    立即提问
    热门标签
    PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有