I am attempting to use AWS SNS for push notifications for my app. I have successfully setup registation of individual endpoints ARN's using user info and regsitration ID.
I can send an individual message via the console fine, however I can't seem to figure out how to send it programmatically (JAVA)
Console way: (Working)
http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-directmobile.html
Attempted way via JAVA:
private void publishToSNSEndpoint(String username) {
// Find an entry of a users SNS registration and Endpoint ARN
SNSPush pushConfig = snsPushService.findByUsername(username);
//Get ARN to String
String endpointARN = pushConfig.getSNSEnpointARN();
//Generate SNS Push to user
String message = "{\"title\":\"Test_Title\",\"description\":\"Test_Description\"}";
PublishRequest publishRequest = new PublishRequest();
publishRequest.setMessage(message);
publishRequest.setTargetArn(endpointARN);
PublishResult publish = client.publish(publishRequest);
//print MessageId of message published to SNS topic
System.out.println("MessageId - " + publish.getMessageId());
}
This currently produces an error of the following:
Using EndpointARN for use (Confirmed valid) Invalid parameter: TargetArn Reason: No endpoint found for the target arn specified (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter;
Using SNS Application ARN (Triple checked this is valid)
Invalid parameter: TargetArn Reason: arn:aws:sns:ap-southeast-xxxxxxxxx-xxxx is not valid to publish to (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter;
There is some documentation here. But it seems pretty old and doesn't work anymore.
My question is: How can I send Push notifications to an individual EndpointARN in AWS SNS programmatically using Java and the AWS SDK.