简体   繁体   English

无法在Titanium中为Android配置推送通知

[英]Unable to configure push notification for android in Titanium

To implement push notification service in my titanium app for android, I was going through this development document. 为了在我的Android钛应用程序中实现推送通知服务,我正在阅读开发文档。 At first, I configured push services for android device by creating a "Client ID". 首先,我通过创建“客户端ID”为Android设备配置了推送服务。 I saved the "Client ID" for further use, but i do not understand where this "Client ID" would be need as there is no information for this in the doc. 我保存了“客户ID”以备将来使用,但由于文档中没有有关此信息的信息,因此我不知道该“客户ID”在何处需要。 Then I followed this doc to subscribe push notification and added "ti.cloudpush" module to the tiapp.xml. 然后,我遵循文档来订阅推送通知,并在tiapp.xml中添加了“ ti.cloudpush”模块。 But unfortunately, I'm getting error while calling retrieveDeviceToken() method. 但是不幸的是,调用retrieveDeviceToken()方法时出现错误。 Here is my code snippet - 这是我的代码段-

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

// 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) {
    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);
});

And here is the error I'm getting in the console - 这是我在控制台中遇到的错误-

Failed receiving GCM SenderId. Getting GCM SenderId failed. Max retry time reaches.

Note - I didn't add anything for android manifest in tiapp.xml 注意-我没有在tiapp.xml中为android清单添加任何内容

When you're using Cloudpush module you will also need to configure the backend with settings. 使用Cloudpush模块时,还需要使用设置配置后端。 You can find how to do that in the documentation: https://docs.appcelerator.com/platform/latest/#!/guide/Configuring_push_services-section-src-37551713_Configuringpushservices-ConfiguringpushservicesforAndroiddevices 您可以在文档中找到如何执行此操作: https : //docs.appcelerator.com/platform/latest/#!/guide/Configuring_push_services-section-src-37551713_Configuringpushservices-ConfiguringpushservicesforAndroiddevices

If you want to use your own backend you will need to use a different module for sending push notifications on Android. 如果您想使用自己的后端,则需要使用其他模块在Android上发送推送通知。 For example ti.goosh or onesignal 例如ti.gooshonesignal

The documentation of both modules will tell you how to configure the senderID. 这两个模块的文档将告诉您如何配置senderID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM