SNS Mobile push notifications extremely confused - android

Right now I'm trying to send mobile push notifications to my phone when someone publishes a message to SNS. I'm confused about what services I have to use. Do I have to use a 3rd party service like Firebase Cloud Messaging/GCM to send mobile push notifications? Or can I send it directly from SNS to my phone.
In AWS docs it's a bit contradicting to me.
https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html
It says:
To begin using Amazon SNS mobile push notifications, you need
the following:
A set of credentials for connecting to one of the supported push
notification services: ADM, APNS, Baidu, FCM, MPNS, or WNS.
A mobile app that is registered and configured to use one of the
supported push notification services.
So that means we have to use a third party service right? But however in one of the AWS SNS tutorials:
https://docs.aws.amazon.com/sns/latest/dg/mobile-platform-endpoint.html
it says we can create a platform endpoint for my mobile device so that it can recieve push notifications. I am extremely confused, do we have to use a third party service or can we send SNS push notifications directly to our phone?
I checked stackoverflow and the answers are not clear to me either
Can Amazon SNS push notifications directly to mobile devices?
Amazon SNS Sending direct push notification to individual device
Can someone please clarify this for me?

AWS SNS manages and abstracts different push notification services.
For AWS SNS to be able to make use of the appropriate push notification service, it would need a platform endpoint. It would need to know which platform (i.e iOS) an app is built.
it says we can create a platform endpoint for my mobile device
To create a platform endpoint, you would need a certificate coming from the Push Notification provider.
Example: .p12 is a certificate from Apple which will require "Push Notification" feature to be enabled.
Once a platform application is created, the app would need to register a unique device token to AWS SNS.
This device token is generated by iOS or Android to uniquely identify the device. The app can only generate the device token if it's properly signed by a certificate from the Push Notification provider.
do we have to use a third party service
Yes you need a third party service to:
generate the certificate with push notification feature enabled
generate the device token associated with your physical device
properly sign the app using the certificate
or can we send SNS push notifications directly to our phone?
AWS SNS manages this for you by matching device endpoints to the correct device token. Then invoking the appropriate push notification service. (i.e APNS, GCM).

Related

Is it possible to send push notification through APNS to device token generated via FCM?

In the project , I am generating device token for both IOS and Android using FCM. And push notifications . In my research, I found push notifications can be sent with https://fcm.googleapis.com/fcm/send
But is it possible to send push notification to IOS device, By using APNS api.sandbox.push.apple.com to the token generated with FCM ?
Apple docs Link
No. Api.sandbox.push.apple.com can only be used with Tokens generated by Apple. You need to fetch the Apple token in the client using didRegisterForRemoteNotificationsWithDeviceToken and send it to your server.
BTW, the Firebase SDK does exactly that and fetches this token in order to send iOS notifications. For each FireBase token they fetch the relevant Apple token from the device and use it when connecting to the Apple servers.

Push notification not working in Amazon SNS

I am using Amazon AWS Mobile Hub in my app. I have configured the push notification feature. In the sample app provided by AWS the push notification registration is also successful. I can check the end point and subscription data in SNS portal.
But if I publish any message its not displaying in my App. Also in my Google Project the GCM data is nil.
While creating a project in Google API for GCM it provides a project name and an ID number.
I was submitting the name in Amazon AWS but it should be the ID number.
You mentioned GCM, so I'm assuming you're on Android. Are you using an AVD image in the Android Emulator or on an actual device?
How are you sending the push message? If you're using the Amazon SNS console, you can select the topic and push a message with Raw type and just put "Test" in the payload and it should show up.
One thing to check is that your device is not on a corporate or other VPN network which restricts any network access in its firewall rules. I know GCM push does not work consistently on our internal corporate LAN because of such firewall rules.

Is there any specific reason to use Amazon SNS instead of direct Baidu service

I have created push notification using Baidu. It works well through Baidu console and I receives the notification in my Android mobile.
I have to create a webservice to send push message from my specific application by using the SDK provided by Baidu. I have another option which seems to be available under Amazon SNS. It seems like a wrapper to Baidu, GCM etc.
My doubt is is there any specific advantage for using Amazon SNS over the Baidu provided SDK?
tldr;
If you target the chinese market only and Baidu is working well for you and you have all you code setup to work with Baidu, then stay with Baidu
Some other points to clarify about Amazon SNS
Baidu cloud push offers a really good service if you want to send notification on the chinese market
Amazon SNS on the other side is a much larger offering and as part of the Mobile Push Notifications Amazon will act as an abstract layer and you can choose which implementation you want.
It has the following advantages:
You are not limited to Baidu scope so you can send notification on the chinese market but not only and if/when needed to send a notification abroad it will be much easier without rewriting the whole thing
You can use the same code and change quickly the provider for push notification in case the provider does not work at a given time (downtime operations) or if the conditions change and you're not happy with new conditions.
You send push notification messages to both mobile devices and
desktops using one of the following supported push notification
services:
Amazon Device Messaging (ADM)
Apple Push Notification Service (APNS) for both iOS and Mac OS X
Baidu Cloud Push (Baidu)
Google Cloud Messaging for Android (GCM)
Microsoft Push Notification Service for Windows Phone (MPNS)
Windows Push Notification Services (WNS)
The following figure shows an overview of how Amazon SNS is used to
send a direct push notification message to a mobile endpoint.

how to get SNS working in Android?

how to get SNS working in Android?
We have an app that sends SNS messages to iOs apps already (I personally am only working with the App side). And have extended it to send Android messages. It works fine for iOS and thinks it is sending to Android correctly but no message ever actually shows up on the Android device.
I am registering with the backend by getting the Settings.Secure.ANDROID_ID and sending that to the web service that registers it with Amazon SNS.
I have turned on all the permissions that I can (I don't need to specifically ask for permission do I?, how would I do that).
Basically the setup we have is I hand our web service a device id and it registers with Amazon and the web service sends the notifications out (but I am never seeing them).
Is there anything else I need to do or check on the client side?
Amazon SNS for push messaging on android instructions is the same as normal GCM on android.
You must follow the directions here:
GCM Getting Started - covers the google console set up and will provide you with the :
SenderId, for use in the android app code. (This is the Google Console's Project #)
the api key, for use in SNS server setup
Implementing GCM Client - covers client library, getting the registration ID, setting up a wakeful service and broadcast receiver for creating notifications or whatever you'd like you app to do when it receives a push.
You should also read thru amazon's documentation Getting Started with Google Cloud Messaging for Android which summarizes the the previous two links.
I am registering with the backend by getting the Settings.Secure.ANDROID_ID and sending that to the web service that registers it with Amazon SNS.
This is not correct. By using the GCM client library, call the following methods to get the real registration ID (sns likes to call them an endpoint) that you can send to the web service that registers it with Amazon SNS. There should be no need to use Settings.Secure.ANDROID_ID at all for push on android.
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(someContext);
String registrationId = gcm.register(senderId);
I have turned on all the permissions that I can (I don't need to specifically ask for permission do I?, how would I do that).
see Implementing GCM Client for the required permissions that you must include in your AndroidManifest.xml. And no, you don't need to specifically ask for permission since it would be in the AndroidManifest.xml but you could ask the user on first app start with a dialog or some other UI. You may also choose to let the user disable push for you app via a settings screen if your app has one.
Is there anything else I need to do or check on the client side?
You should confirm that you are able to get registration ids (perhaps some logging)?
And then with those ids, test your implementation. Here is a question that was asked a while ago that will help you use a rest client to send pushes with your registration ids and api_key (SNS login not needed).
How to push notification from rest client for testing purpose

Is Google Cloud Messaging from Android to Android possible?

I read about Google Cloud Messaging at http://developer.android.com/google/gcm/gcm.html.
It supports Third Party Application server to Android application push notification.
I am wondering whether it is possible to implement the same thing push/receive notification from an Android app on one mobile to the same Android app on another mobile using Google Cloud Messaging.
If not, is there any other free service available similar to Google Cloud Messaging?
An Android device can send a GCM message to another Android device. All it needs is the API Key (of the Google API Project ID that the app uses to register to GCM) an the Registration ID of the other device. Using these parameters it can send a GCM message to another device via an HTTP request.
Usually applications that use GCM require a 3rd party server in order to store the Registration IDs of all registered devices. If your app has a different way to let devices share their Registration IDs with each other without requiring a server, you don't need the server.
As far as I'm aware, there has to be a server in the middle to send the push notifications (Android -> Personal Server -> GCM Server -> Android)
So the Android device sending the notification would send some data to a script on the server (using a HTTP GET/POST), and that script would then send the push notifications to all the devices that you wanted it to
Following the example Code from google (GCM Client Example), you can build an app to get a registration ID for your device, but sending messages without a server wouldn't work in my opinion. I didn't tried by now, but what about using the Google Backend Starter, or (what I tried) using a Backend as a Service Provider like apiOmat if you can't afford or don't want to set up a server.

Categories

Resources