我需要在Android设备之间为AWS Mobile Hub项目发送推送通知。它只是设备到设备消息传递,不涉及任何主题。我已经集成了FCM和PinPoint
pinpointManager.getNotificationClient().registerDeviceToken(newToken)
我使用此代码获取endPointID
String epID = pinpointManager.getTargetingClient().currentEndpoint().getEndpointId();
我可以使用上面的endPointID成功地从PinPoint控制台将消息推送到设备。但我想从Android设备本身推送。但是,由于PinPoint Android SDK中没有任何发布API,我已经集成了SNS。我正在尝试使用从PinPoint接收的endpointID使用此代码发布SNS:
PublishRequest publishRequest = new PublishRequest();
publishRequest.setTargetArn(epID);
publishRequest.setMessage("Hello from android");
AmazonSNSClient snsClient = new AmazonSNSClient(App.getCCCProvider());
snsClient.publish(publishRequest);
但收到以下异常
com.amazonaws.services.sns.model.InvalidParameterException:无效参数:TargetArn原因:ARN必须至少有6个元素,而不是1(服务:AmazonSNS;状态代码:400;错误代码:InvalidParameter;请求ID: 7ff39768-c6f9-5a6e-8211-c5ec586276fb)
如果有帮助,我的endpointID是:1fa93529-a5ac-4d70-995a-be1584c68a37
你们的任何指针或解决方案?
答案 0 :(得分:1)
您正在寻找的API是Pinpoint.sendMessages
API。
您的请求可能类似于:
amazonPinpoint.sendMessages(
new SendMessagesRequest()
.withApplicationId("APP_ID")
.withMessageRequest(
new MessageRequest()
.withMessageConfiguration(
new DirectMessageConfiguration()
.withGCMMessage(
new GCMMessage()
.withBody("Hello from android")
)
)
.addEndpointsEntry(
"DESTINATION_ENDPOINT_ID",
// You can provide overrides and the like here
new EndpointSendConfiguration()
)
)
)