According to the GCM Advanced Topics, under the part of "How unregistration works", GCM notifies the 3rd-party server that a registration id is no longer registered with the device. When we use Amazon SNS, the 3rd-party is Amazon. What I'm unclear on is SNS does when when GCM sends it NotRegistered for a registration id.
Does Amazon delete the SNS topic? If so, how do I know on my application server to remove my reference to it? If not, how am I expected to clean up my list of SNS topics assigned to a user?
Amazon SNS sets the endpoint to "Disabled". You can subscribe to EventEndpointCreated events to receive this notification.
From the Amazon SNS FAQ:
How does SNS Mobile Push handle token feedback from notification services?
SNS Mobile Push automatically handles token feedback services on your behalf, and exposes the feedback information via events published to a topic you may choose to consume. This approach reduces the operational burden of sending push notifications, and maximizes the speed and reliability with which your notifications are delivered. Push notifications services such as APNS and GCM provide feedback about tokens which may have expired or been replaced by new tokens. When a particular token is replaced by a new token, SNS automatically updates the associated endpoint, and notifies you via an event. When a particular token expires, perhaps because a user deleted your app, SNS marks the endpoint as disabled and notifies you via an event. You don’t strictly need to consume the feedback notifications in order to send push notifications with SNS, but may choose to do so based on your broader use case.
Related
In Firebase cloud function can send push notification to any user if the user device token is stored in Firebase database. Again if the user subscribes to a topic then also another user can send a notification to the user. Now the question is that in what situation we should use topic messaging and in what situation we should use cloud function to send the notification. If any user subscribes to his unique ID (as provided by Firebase) then anyone can send topic messaging to him by publishing topic messaging to that unique ID. Is it a good approach or we should use cloud function to send push notification to that user using the device token. Is it a good idea to subscribe to his own unique ID to get a notification. Please help me to resolve my issue. Is topic messaging is free to use?
Firebase Cloud Messaging is completely free to use, including the use of topics.
When you use topics, you separate the sending of messages about a topic, from the fact that an install of your app subscribes to that topic. This means you can add subscribers to the topic later, without having to write additional code or even data (as the list of tokens that are subscribed to a topic is handled by FCM itself).
On the other hand: topics are public. Once somebody knows the topic ID, they can subscribe to that topic, and receive any messages you send to that topic.
The alternative to using topics is sending messages directly to FCM Instance ID tokens. In that case you'll keep a list of tokens somewhere yourself, and determine what token(s) to deliver the message to. In this case, you fully control who receives the message, but will have to maintain your own list of tokens, and the mapping of what token receives what message(s).
Note that sending messages (no matter whether to topics or to tokens) can be done from any trusted environment, like your development machine, a server you control, or Cloud Functions. And sending messages (no matter whether to topics or to tokens) can't be (securely) done from the client-side code.
Hi does amazon SNS support tracking of opened push notifications?
If not, is there a third party analytics service that can track opened notifications in apps (ios android) and combines count of delivered notifications from amazon SNS?
Message delivery can be tracked using Amazon SNS Delivery Status and Amazon CloudWatch:
You can capture information on success rates, failure rates and dwell times for mobile push notifications using Amazon SNS Delivery Status. These metrics provide insights such as whether your push notifications have been successfully delivered to the intended messaging platform and the time it took for the notifications to be delivered. In addition to collecting status information, you can also trigger alerts based on metrics you define in Amazon CloudWatch.
You can enable this feature by simply selecting to receive “Delivery Status” for your applications in the Amazon SNS console. After this is enabled, the information is captured in an Amazon CloudWatch Logs group that is automatically created by Amazon SNS on your behalf.
See the initial announcement of this feature.
It’s also described here in this AWS YouTube video:
How do I confirm delivery of Amazon SNS Push Notifications and find out why some notifications fail
My Android client app does not receive any Firebase push notifications targeting topics, however I immediately receive notifications sent to all app users or notifications sent to specific devices.
I didn't change anything in my code and I checked whether the client is correctly subscribed to topics.
For further details about my subscription logic:
In order to make it easy for my web service to send notifications to a specific user, each user is subscribed to a topic entitled with his user-id whenever he logs in from the client app.
Is this approach weak somehow? Should I otherwise register the device token to my database every time it's updated? And then send the notification to that specific token?
Should I otherwise register the device token to my database every time it's updated? And then send the notification to that specific token?
It is highly suggested that developers save the generated registration token for each device for later use. As mentioned in the docs:
After you've obtained the token, you can send it to your app server and store it using your preferred method.
In your case, it is preferable. It'll remove the added action of subscribing the device to a topic. Plus it can be useful to track the message status using Diagnostics tool should you need it in the future.
I want to know whether AWS SNS (Simple Notification Service) delivery receipts indicate:
whether AWS SNS delivered the push notification just to the relevant push notification service (e. g. GCM, APNS), or
whether the push notification was actually delivered to the mobile phone of the targeted user
The documentation appears vague on this.
I'd also like to know if, in case the second case above is true, whether the delivery receipts are also delivered when the app has been force-killed by the user.
SNS supports GCM over HTTP only, so you will only know when SNS has delivered the message to GCM not to the device. In order to get a delivery receipt that the message has been received by the device you would have to use XMPP.
See the docs for more.
I am working on integrate GCM to the android app, my working flow is first whenever the user enter the app, it check whether the share pref. has the gcm id, if not , then reg and save to share pref.
The problem is, it seems the id is duplicate after I install the app again. For example, if I install three times, then the app will receive three times of the message.
As I am using Amazon SNS service , the GCM id is store in their database, how can I handle the case of user re-install the app to prevent register again?
Thanks
if (gs.settings.getString("endpoint_arn", "").equals("")) {
gcm = GoogleCloudMessaging.getInstance(ctx);
asnsc = new AmazonSNSClient(new BasicAWSCredentials(Constant.id,Constant.secret));
asnsc.setRegion(Region.getRegion(Regions.AP_SOUTHEAST_1));
asnsc.setEndpoint("sns.ap-southeast-1.amazonaws.com");
new AsyncTask() {
#Override
protected Object doInBackground(final Object... params) {
try {
CreatePlatformEndpointRequest per = new CreatePlatformEndpointRequest();
per.setToken(gcm.register(Constant.projectID));
per.setPlatformApplicationArn(Constant.platformARN);
CreatePlatformEndpointResult result = asnsc.createPlatformEndpoint(per);
String arn = result.getEndpointArn();
gs.editor.putString("endpoint_arn", arn).commit();
}
}
You have to check for these 3 steps in order to set up everything working:
Firstly unregister the old registration id before you register the new id as mentioned in the comments.
Secondly, when you unregister, you should send the old registration ID to your server and remove it from your database.
If after registering and getting the new registration ID you send a message with the old registration ID, Google will respond you with a new registration id. This response indicates that your server should delete the old registration ID and use only the new one.
(Assume that your server had subscribed SNS EndpointUpdated Event)
When you send the message by old registration id, it will trigger SNS changed the old registration id to new registration id in Aws SNS database which you check in the SNS console.
In the same time, the SNS will send you a feedback about EndpointUpdated.
Using the endpoint arn in the feedback, you can check the token of the endpoint. The token of the endpoint in AWS database is different from your database, you can delete_endpoint in AWS and also delete the device record in your database. So you can clean up the database.
However, there is a potential problem of above practice. In case, you failed to receive the feedback. You will still send duplicate notifications to users. I still figuring out how to deal with it. lol
According to Amazon SNS FAQ:
How does SNS Mobile Push handle token feedback from notification services?
SNS Mobile Push automatically handles token feedback services on your behalf, and exposes the feedback information via events published to a topic you may choose to consume. This approach reduces the operational burden of sending push notifications, and maximizes the speed and reliability with which your notifications are delivered. Push notifications services such as APNS and GCM provide feedback about tokens which may have expired or been replaced by new tokens. When a particular token is replaced by a new token, SNS automatically updates the associated endpoint, and notifies you via an event. When a particular token expires, perhaps because a user deleted your app, SNS marks the endpoint as disabled and notifies you via an event. You don’t strictly need to consume the feedback notifications in order to send push notifications with SNS, but may choose to do so based on your broader use case.