【问题标题】:blackberry webworks/phonegap push notfication not working黑莓网络工程/phonegap 推送通知不起作用
【发布时间】:2013-10-09 05:12:21
【问题描述】:

我正在尝试在我的 phonegap 应用程序中实现 bb os 6 和 7 的推送通知

之后显示错误警报,我也没有在设备上收到推送通知。

我正在使用 pushwoosh 服务器发送通知,请指出我的代码出了什么问题

var port = 33981; //THE_PORT_FROM_BB_REGISTRATION;
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = "4223-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var max = 100;
var wakeUpPage = "index.html";

function openBISPushListener() {
    try {
        var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};
        //alert("obj = " + ops.wakeUpPage);
        alert(blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange));
    alert("success push");  
    }
    catch (err) {
        alert("Called openBISPushListener():Error - " + err);
        //alert(err);
    }    
}

function onRegister(status) {       
    alert("status" + status);
    if (status == 0) {      
        PushWoosh.register(function(data) {
                    alert("PushWoosh register success: " + JSON.stringify(data));
                }, function(errorregistration) {
                    alert("Couldn't register with PushWoosh" +  errorregistration);
                });    
    }
    else if (status == 1) {
        alert("push register status network error");
    }
    else if (status == 2) {
        alert("push register status rejected by server");
    }
    else if (status == 3) {
        alert("push register status invalid parameters");
    }
    else if (status == -1) {
        alert("push register status general error");
    }
    else {
        alert("push register status unknown");
    }
}

function onData(data) { 

    alert("Push notifications received. Data is " + blackberry.utils.blobToString(data.payload));
    try {
        return 0; //indicate acceptance of payload for reliable push
    }
    catch (err) {
        alert("Called onData():Error - " + err);
    }
}

function onSimChange() {
    //handle Sim Card change
    alert("sim changed");
}

【问题讨论】:

  • 您收到什么状态?你应该得到状态 0
  • 首先它显示代码警报的警报“未定义”(blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange));它在警报中显示“错误”,然后当我关闭应用程序并重新打开它时什么也不显示,然后警报显示为打开 openBISPushListener() 时出错

标签: cordova push-notification


【解决方案1】:

我自己也在做这件事。到目前为止,我遇到的两个障碍是: - 您需要启用黑莓互联网服务才能注册设备(您可以检查:状态栏中的wifi图标旁边应该有一个小黑莓图标) - 在 Pushwoosh 设置中,PPG url 需要是 HTTPS,而不是像 blackberry 的电子邮件中的 http

这使我能够注册设备并成功从 PushWoosh 发送通知。 (不幸的是仍在努力让通知到达我的设备)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多