gpt4 book ai didi

javascript - 注册设备上的 Pushwoosh 回调

转载 作者:行者123 更新时间:2023-11-30 06:34:27 24 4
gpt4 key购买 nike

我一直在尝试使用 phonegap(适用于 Android)将 pushwoosh 实现到我基于 javascript 的应用程序中。

我已经完成了他们的教程和示例,而且我还能够将设备注册到 GCM 服务器以获取通知。但不知何故,我没有收到注册设备的回调。

代码在这里:

function initPushwoosh()
{
var pushNotification = window.plugins.pushNotification;
pushNotification.onDeviceReady();

//projectid: "581719621125", appid : " EB8C9-89549"
pushNotification.registerDevice({
projectid: CONFIG.projectID,
appid : CONFIG.appId
},
function(token) {
console.warn('Push token onPushwooshInitialized : ' + pushToken);
onPushwooshInitialized(token);
},
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;

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

navigator.notification.alert(title);

pushNotification.stopGeoPushes();
});

如您所见,registerDevice 采用的第一个函数用于成功回调,另一个用于失败/错误。

我在 eclipse Log Cat ( Console ) 中看到的是这样的

03-19 10:23:35.339: V/GCMRegistrar(548): Is registered on server: true03-19 10:23:35.369: W/dalvikvm(548): Exception Ljava/lang/RuntimeException; thrown during Landroid/os/AsyncTask;.03-19 10:23:35.399: W/PushWoosh DeviceFeature2_5(548): Try To sent AppOpen03-19 10:23:36.669: I/global(548): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.03-19 10:23:36.669: W/PushWoosh: NetworkUtils(548): PushWooshResult: {"status_code":200,"status_message":"OK","response":null}03-19 10:23:36.679: W/PushWoosh DeviceFeature2_5(548): Send AppOpen success03-19 10:23:36.749: I/dalvikvm(548): Rejecting re-init on previously-failed class Lcom/arellomobile/android/push/utils/WorkerTask; v=0x003-19 10:23:36.749: W/DeviceRegistrar(548): Try To Registered for pushes03-19 10:23:37.569: I/global(548): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.03-19 10:23:37.580: W/PushWoosh: NetworkUtils(548): PushWooshResult: {"status_code":200,"status_message":"OK","response":null}03-19 10:23:37.590: V/GCMRegistrar(548): Setting registered on server status as: true03-19 10:23:38.039: W/PushEventsTransmitter(548): No android.permission.BROADCAST_STICKY. Reverting to simple broadcast03-19 10:23:38.120: W/DeviceRegistrar(548): Registered for pushes: APA91bFK0pv-d1gorQOs2lY_CJMYlNCkoLPWlHsO7oZyLa4gLzQqHnKGKW0mUyiW-llXpoWGpPpLPJAm1vY-Bxi_jnG462NIg2r7gvszqJBQt3wY69WsKnhq-_dgsqXRJ_m_KhoP4uS-2k7FM68LEs3cnCLZqjXHiA

如您所见,最后一行表示设备已成功注册,并且有从服务器获取的 token /注册 ID,但由于它没有调用我的回调函数,所以我无法处理这些事情。你用谷歌搜索但没有找到解决方案,我不确定他们在我这边的代码中是否有任何逻辑问题。非常感谢任何有用的链接和支持。

最佳答案

请从以下位置获取新的 Pushwoosh.jar: https://github.com/shaders/phonegap-cordova-push-notifications/tree/master/Android/lib

或者在这里: https://github.com/shaders/push-notifications-sdk/tree/master/SDK/Android

(他们是一样的)

您看到的行为是由于这一行:03-19 10:23:38.039:W/PushEventsTransmitter(548):没有 android.permission.BROADCAST_STICKY。恢复为简单广播

有两种方法可以将注册传输到应用程序,Phonegap Pushwoosh 插件尚不支持这种方式(广播)。不知何故,这个变化设法出去了......

更新到新的 Pushwoosh.jar 应该会有帮助。请告诉我进展如何。

关于javascript - 注册设备上的 Pushwoosh 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15491831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com