大家好,这个问题让我抓狂,我正在尝试为 phonegap 应用 pushwoosh sdk,但它似乎无法正常工作!我已经从我的配置文件中检查了所有内容,其中包含“aps-envierment”,所有推送证书都已配置。 p12 aps 开发一切,但设备只是不注册! 我的 index.html 示例代码
我在 config.xml 中配置了插件 pushwoosh 的所有带有 .h .m 的插件文件夹都在插件文件夹内,一切都编译正常,只是在运行时没有得到注册提示,如果有人能提供帮助,我们将不胜感激。
<script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
function initPushwoosh()
{
alert('initing pushwoosh');
var pushNotification = window.plugins.pushNotification;
pushNotification.onDeviceReady();
pushNotification.registerDevice({alert:true, badge:true, sound:true, pw_appid:"*****the right id just hidden", appname:"testingNewPush"},
function(status) {
var deviceToken = status['deviceToken'];
console.warn('registerDevice: ' + deviceToken);
},
function(status) {
console.warn('failed to register : ' + JSON.stringify(status));
//navigator.notification.alert(JSON.stringify(['failed to register ', status]));
});
pushNotification.setApplicationIconBadgeNumber(0);
document.addEventListener('push-notification', function(event) {
var notification = event.notification;
navigator.notification.alert(notification.aps.alert);
pushNotification.setApplicationIconBadgeNumber(0);
});
}
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady(){
alert('device');
initPushwoosh();
app.receivedEvent('deviceready');
}
</script>
<title>Hello World</title>
</head>
<body onload="onBodyLoad()">
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
</body>
最佳答案
你看到警报了吗:alert('initing pushwoosh')?
如果您没有看到“允许推送通知”弹出窗口,请仔细检查您使用的配置文件中是否包含“aps-environment”字符串。但是,如果您尝试使用未启用推送的配置文件运行,SDK 应该会向您发出警告。
到目前为止代码对我来说看起来不错,来自控制台的一些日志可能真的有帮助。
附言 据我所知,Pushwoosh 可以快速查看高级帐户的集成代码。但您必须联系他们的支持人员进行确认。
关于ios - phone-gap 2.8 和 pushwoosh 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17134167/