【问题标题】:getDeviceToken of android without cloudpush没有cloudpush的android的getDeviceToken
【发布时间】:2016-05-16 13:17:11
【问题描述】:

我正在 Android 上集成推送通知。

根据应用加速器article

// notification setting
var deviceToken = null;

// Require the module
var CloudPush = require('ti.cloudpush');

// Initialize the module
CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});

// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
    Ti.API.info("deviceTokenSuccess :" + e.deviceToken);
    deviceToken = e.deviceToken;
}
function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}

// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
    alert("Notification received: " + evt.payload);
});

我需要获取 deviceToken 才能将通知推送到 android,但此脚本使用 CloudPush,它需要“titanium Arrow 服务”登录。

但是我想使用亚马逊 SNS 服务而不是“箭头服务”来推送消息,并且不想使用箭头服务。

(我已经完成了亚马逊SNS设置,iOS推送成功。)

如何在不使用 cloudpush 的情况下获取 android deviceToken。

有可能吗?

【问题讨论】:

  • 在这种情况下,您将需要另一个模块来帮助您。 Cloudpush 只是一个例子。
  • 您知道,您可以在没有 ACS 的情况下使用 Cloudpush,只需让另一个平台为您发送推送。 Cloudpush 只是接收端
  • 谢谢@RentPot,如果我使用cloudpush获取deviceToken,我在哪里可以设置senderID和Apikey? (可能在 tiapp.xml...?或方法?)我用谷歌搜索,但除了使用 ACS 登录外找不到答案。

标签: android push-notification google-cloud-messaging titanium appcelerator


【解决方案1】:

您可以使用https://github.com/morinel/gcmpush获取设备令牌

【讨论】:

  • 谢谢@miga,我下载并编译,但是得到这个错误[错误] 找不到所有必需的钛模块:[错误] id:nl.vanvianen.android.gcm 版本:最新平台:android部署类型:测试
  • 我无法从源代码安装这个模块,可能是编译过程有问题。我可以得到模块本身吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-22
  • 1970-01-01
  • 2011-03-15
  • 1970-01-01
  • 2012-08-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多