我正在尝试向服务器发送推送通知,然后使用FCM和Amazon SNS将该数据传输到客户端应用程序。
我已经实施了以下内容。
String customPushData = "my custom data";
CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest();
platformEndpointRequest.setCustomUserData(customPushData);
platformEndpointRequest.setToken(token);
platformEndpointRequest.setPlatformApplicationArn(platformApplicationArn);
pushClient.setRegion(Region.getRegion(Regions.AP_NORTHEAST_1));
CreatePlatformEndpointResult result = pushClient.createPlatformEndpoint(platformEndpointRequest);
String endpointArn = result.getEndpointArn();
当我试图调试这个时。然后,
光标没有从
移动CreatePlatformEndpointResult result = pushClient.createPlatformEndpoint(platformEndpointRequest);
当我在 console.aws.amazon.com/sns 中签入我的应用程序时,没有注册令牌。
我哪里错了,如何处理将数据发送到sns并返回另一台设备?
任何肝脏都会非常感激。
答案 0 :(得分:0)
最后,我使用以下方式使其工作。
我已加入AsyncTask
并执行以下更改。
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... params) {
AWSCredentials awsCredentials = new BasicAWSCredentials("access Key", "secret Key");
AmazonSNSClient pushClient = new AmazonSNSClient(awsCredentials);
CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest();
platformEndpointRequest.setToken(regToken);
platformEndpointRequest.setPlatformApplicationArn(platformApplicationArn);
pushClient.setRegion(Region.getRegion(Regions.Region_Name));
CreatePlatformEndpointResult result = pushClient.createPlatformEndpoint(platformEndpointRequest);
Log.e("Registration result",result.toString());
return null;
}
我收到了endpointARN作为回应。