直接注册设备ID与Amazon SNS直接、设备、ID、Amazon

2023-09-05 11:09:27 作者:被遗忘的记忆

我使用的是亚马逊网络服务直接发送推送通知到设备。我安装的应用程序,我得到的设备ID,我需要手动添加到Amazon SNS。我想知道是否有无论如何直接与亚马逊的服务器注册的设备ID的用户启动应用程序的那一刻。

I am using the Amazon Web Service to send push notifications directly to a device. After I install the app I get the device id, that I need to manually add to the Amazon SNS. I would like to know if there is anyway to register the device id directly with the amazon server the moment the user starts the application.

我已经阅读这,但发现很难了解。有没有人对如何做到这一点任何previous经验?

I have read this, but found it difficult to understand. Does anyone have any previous experience of how to do this?

编辑2(我迄今所做的)

我已经按照从此链接

我下载snspobilepush.zip文件的指示并提取并导入项目到Eclipse中。我想补充的GCM项目数量,增加的jar文件并运行应用程序。我得到我的设备注册ID。

I download the snspobilepush.zip file as instructed and extract and import the project into eclipse. I add the GCM project number, add the jar files and run the application. I get my device registration Id.

我打开亚马逊SNS,加上我的设备ID和我发布一条消息。我收到我的手机的消息。伟大的工程至今。

I open the Amazon SNS, add my device id and I publish a message. I receive the message on my mobile phone. Works great so far.

我的问题

我将有很多潜在用户对我的申请。所以手动添加每个设备ID到SNS是没有意义的。我需要亚马逊SNS直接注册我的设备ID,当我启动应用程序。是否有任何选择,我这样做呢?我找不到在文档的任何明确的答案。 此链接告诉我使用AWS令牌自动贩卖服务。但是,我无法找到如何做到这一点的任何例子。

I would be having a lot of potential users for my application. So adding every device id manually to the SNS makes no sense. I need the Amazon SNS to directly register my device id when I start the app. Is there any option for me to do that? I couldn't find any definitive answer in the docs. This link tells me to Use the "AWS Token Vending Service". However, I could not find any example of how to do that.

推荐答案

使用AmazonSNSClient这里记载:

Using the AmazonSNSClient documented here:

http://docs.aws.amazon.com/AWSAndroidSDK/latest/javadoc /

应该可以使用code与此类似注册:

it should be possible to register using code similar to this:

AWSCredentials awsCredentials = new BasicAWSCredentials("XXXXXX", XXXXXXXXXXXXXXX");
String platformApplicationArn = "arn:aws:sns:us-east-1:123456789:app/GCM/myappname";
pushClient = new AmazonSNSClient(awsCredentials);

String customPushData = "my custom data";
CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest();
platformEndpointRequest.setCustomUserData(customPushData);
platformEndpointRequest.setToken(pushNotificationRegId);
platformEndpointRequest.setPlatformApplicationArn(platformApplicationArn);
CreatePlatformEndpointResult result = pushClient.createPlatformEndpoint(platformEndpointRequest);
Log.w(TAG, "Amazon Push reg result: " + result);

有人不喜欢我的ARN,但是这是一个愚蠢的错字里德指出,目前上述固定的。

It was not liking my ARN, but that was a stupid typo that Reid pointed out and is now fixed above.