首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在xdk (英特尔)上实现pushwoosh

如何在xdk (英特尔)上实现pushwoosh
EN

Stack Overflow用户
提问于 2014-09-23 08:25:43
回答 1查看 1.1K关注 0票数 0

我已经遵循了Pushwoosh网站上建议的所有步骤,但仍然会出现以下错误:

Uncaught TypeError: Cannot read property 'pushNotification' of undefined,请帮帮我!

有关我的代码的更多信息:

  1. "https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git"-> i安装了插件源代码
  2. 白名单*.pushwoosh.com域在config.xml文件中:->I没有这样做,因为xdk应该自动完成它

3.注册推送通知:在javascript文件中添加以下函数,输入正确的项目编号和Pushwoosh应用程序ID

代码语言:javascript
复制
 $( document ).ready(function() {
			  // Handler for .ready() call
			initPushwoosh();
   }
                     
 //push begin
	 function initPushwoosh(){
    var pushNotification = window.plugins.pushNotification;
 
    //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));
        }
                                     
        alert(title);
    });
 
    //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", 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;
            console.warn('push token: ' + pushToken);
        },
        function(status) {
            console.warn(JSON.stringify(['failed to register ', status]));
        }
    );
}
	 
	 document.addEventListener('push-notification', function(event) {
    var title = event.notification.title;
    var userData = event.notification.userdata;
 
    console.warn('user data: ' + JSON.stringify(userData));
    alert(title);
});
	 
	 //push end

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-23 11:03:24

检查window.plugins.pushNotification是否为空或未定义。

如果它是null (或未定义),请确保在config.xml中引用插件正确("phonegap“命令应该自动为您完成一切)。

如果你提供更多的信息,我可以改进答案。

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

https://stackoverflow.com/questions/25990325

复制
相关文章

相似问题

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