Appcelerator/Titanium:无法将推送通知发送到Android [英] Appcelerator/ Titanium: Cannot send push notification to Android

查看:98
本文介绍了Appcelerator/Titanium:无法将推送通知发送到Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用Android上的Titanium和Arrow Push发送推送通知.

I want to be able to send push notifications using Titanium and Arrow Push on Android.

我已按照此处的说明进行操作:

I have followed the instructions here:

配置推送服务

订阅推送通知

Modules.CloudPush

我的简单代码如下:

var CloudPush = require('ti.cloudpush');
var deviceToken = null;
    
// Works fine
CloudPush.retrieveDeviceToken({
    success: function () {
        deviceToken = e.deviceToken;
        alert('deviceToken: ' + deviceToken);
        subscribeToChannel();
    },
    error: function () {
        alert('Failed to register for push notifications! ' + e.error);
    }
});
    
// Never runs!!!
CloudPush.addEventListener('callback', function (evt) {
    Ti.API.info('New notification!');
    alert("Notification received: " + evt.payload);
});

// Works fine
function subscribeToChannel () {
    Cloud.PushNotifications.subscribeToken({
        device_token: deviceToken,
        channel: 'general',
        type: Ti.Platform.name
    }, function (e) {
        if (e.success) {
            alert('Subscribed');
        } else {
            alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}

上面的大多数代码与文档相似.该代码的订阅方面似乎工作得很好,因为用户的设备也出现在Appcelerator仪表板的设备"部分中.

Most of the above code is similar to the docs. The subscription aspect of the code seems to works perfectly fine, as the user's device also appears in the devices section of the Appcelerator Dashboard.

但是,当涉及到从Appcelerator仪表板发送的通知时,失败"一词将显示为失败".出现在我的Android设备旁边.

However when it comes to sending a notification, from the Appcelerator Dashboard, the word "Failure" appears next to my Android device.

突出显示?"时的完整错误消息.图标如下:

The full error message when highlighting the "?" icon is as follows:

异常类型:GCM;错误代码:3103;错误信息: RegistrationId为null或为空;捕获的异常:参数不能 为空

Exception Type: GCM; Error Code: 3103; Error Message: RegistrationId(s) is null or empty; Catched Exception: argument cannot be null

我在 http://docs.appcelerator上查找了此错误. com/arrowdb/latest/#!/guide/疑难解答,它的意思是:

GCM客户端提供了一个空或空的注册ID.这个错误是 如果您使用的是Modules.CloudPush模块,则不常见.

The GCM client provided a null or empty registration ID. This error is uncommon if you are using the Modules.CloudPush module.

这没有帮助.

我做错了什么?这是Accelerator方面的错误吗?

What am I doing wrong? Is this a bug on Accelerator side.

推荐答案

结果证明我的代码很好.我使用的凭据不正确.请在这里查看我的其他相关问题:

Turns out my code was fine. The credentials I was using however was incorrect. Please see my other related question here:

Appcelerator/Titanium:获取Android凭据来推送通知

文档需要更新.

这篇关于Appcelerator/Titanium:无法将推送通知发送到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆