Using a serverless architecture built on AWS, I'm looking for the best way to have users receive near-instant notifications of new "chats" within my Android app. I don't necessarily want to see a push notification appear in the phone's notification tray - I just want the app to listen for new messages, and update the view accordingly.
Here's my thinking: every time a user sends a chat, I'd basically trigger a Lambda function which would call SNS or IoT to publish the notification to any subscribed users of this chat.
But since SNS / IoT both work by sending "push notifications" to the phone, does that mean the message would have to appear within the phone's notification tray? I'm just looking for a way for my app to silently receive near-instant notifications from AWS and execute code to update its view.
Some other notes:
1) I don't want to build this using a server / EC2 with websocket listeners - I'd rather go serverless.
2) I've looked in Google's Firebase real-time DB which looks very capable, but as the rest of my architecture is on AWS, I'd like to stay there if possible
If you are making app for Android only, you can make use of the data message in FCM from Firebase. You can handle the message in onMessageReceived no matter your apps is on Foreground or Background.
Apart from that, firebase provide integration with most server side language. You should be able to send the message in your lambda function.
my suggestion is using FireBase...
and make your Json tag with "data" than "Notification"
Related
I want to setup some maintenance related messages that would be dispatched to Slack and ideally some mobile users via push notifications (avoiding SMS if I can). I already handled Slack via some SNS + Lambda combo, and I'm tackling the Mobile push part.
I was somehow hoping I could just subscribe my phone number to some SNS channel but I guess its not so simple yet...
If my understanding is correct, it is not possible to receive push notifications without an App, since the Cloud-to-mobile-push service actually needs a client running on the device.
Actually, from what I can read on the internet it would seem most articles and documentations explain how to setup push notifications inside some application along with other features (and basically the push notifications is just one feature amongst the others), and that the push notification is not an end in itself.
However, I am just interested subscribing to push notifications as an end in itself (I don't need any other app feature).
What is the way to proceed in this case ? Are there some generic apps that are made for this and would let me subscribe to any mobile "push-list" ? Are there some kits that let one easily make an app just for the purpose of receiving push messages ? Is there maybe a builtin way in Android/iOS to subscribe to a push list without downloading a different app ?
EDIT : I am in the eu-central-1 region. I have some serviced in eu-west-1 (sending emails to SES) but otherwise all my servers and alarms are in eu-central-1
I am creating mobile application using latest version of Ionic 3. And I am at the point where I need to implement push notifications. I am using FCM. I have managed to done it for Android phones using this plugin: https://github.com/phonegap/phonegap-plugin-push. Reading documentation for this plugin, it says that for Android I should send only Data Messages and that that is the best practice. It also says that send Notification and Data payload would not work properly:
When your app is in the foreground any on('notification') handlers you have registered will be called. If your app is in the background, the notification will show up in the system tray. Clicking on the notification in the system tray will start the app and your on('notification') handler will not be called as messages that have notification payloads will not cause the plugins onMessageReceived method to be called.
But for IOS I need to send notification message with data payload. This would not be a problem if I target directly devices, however I need to send Topic Messages. So the way I see is that on my server I need to implement this logic:
Let's say that the name of topic is FOOD-AND-DRINKS:
function onSomeEvent($data) {
// send push notification to topic ANDROID~FOOD-AND-DRIKS
// send push notification to topic IOS~FOOD-AND-DRINKS
}
Also, since in the future my plan will include multiple cities, and not all people would like to listen for notifications for cities other the one where that person lives, so then my topic would be PLATFORM~CITY~CATEGORY.
So my question would be, is there any better plugin for handling notifications, or some service between my server and Google FCM and that service would take care of that, or this is quite OK what I have proposed?
You can use cloud functions to be able to send notifications since you are using FCM also.
More on this here: https://firebase.google.com/docs/functions/
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
Using cloud functions you can use database triggers like onWrite() and it will be able to send notifications if you have data payload and/or notification.
But if you use data payload alone then you can send if android device is in background also.
Regarding Topics:
If you have multiple cities in your application, then you can let the user register to each topic. You can do in the database like this:
city-category
id_here
cityname: nameX
//other details
id_here1
cityname: nameY
//other details
I have a cross platform application and i want to send notification to sign in users about their messages.
Now I confused about uses of push, local notifications.
What I think of Push notifications is that it is for sending Announcements to users which is not specifically related to their account only.
Can anyone help me out with what should I use? I already used Local notifications in one of my applications with such requirement.
It mainly depends on; is the data coming from local or remote?
You cannot control when your users open the app, and only when they open the app (with a few exceptions) you are able to fetch data. Then with that data you would be able to schedule a local notification. But in most cases that doesn't make much sense, because they have already loaded and probably seen the data. It only makes sense when you schedule an alarm clock for instance.
When you want the data to come from remote, like when they receive a message, you will have to use push notifications. The user is then alerted that new data is available without having to go look for it themselves. It is pushed to them.
However, for push notifications you will need infrastructure which you did not when using local notifications. You will need a server to handle the push notifications (Azure has some awesome functionalities for this) and some trigger to send push notifications. This can be an insert on a database, or a scheduled task. Also, the user has to enable push notifications and your app has to register itself to be able to receive them. It can be a pain to implement it the first time.
It depends on for what reason you're sending the notification.
A local notification is sent locally on the device, so it doesn't need an internet connection. Examples could be:
Send a birthday message when the user has birthday
In a harvesting game, send a local notification when the store is full
A Push Notification is sent from a server and it requires internet on your device to receive it. Examples:
You get a message in a chat while the app is not open (if I understand your question right, this is your case)
In a game: realtime events which are triggered by a server
So in your case, if guess you want to notify the user about new messages if he does not have the app opened. This notification comes from a server and is a Push Notification.
As you describe you want to send notification about sign in users about their messages. so it would be the real time notification about when there is message for user you need to notify the user. so apple having PushNotification is the best approach you need to apply for this. using that you can directly notify user about the new messages.
Why LocalNotification is not useful in this scenario?
I think messaging is the realtime stuff. local notification is not for that. its for only managing local notify stuff. like reminder OR to do added task.. and many more
I was implementing mobile game with my team. And we have argument that push system may not reliable enough. So we should find third party chat message service or open our own chat server instead of relying on silent push notification
But some still belief that using silent push to chat is the standard nowaday and more reliable than implement our own server
The requirement is just to send chat message to active user's chatbox while the app is open
Are there any concern to consider each method?
How about ios and android system setting?
Will our app receive surely recieve silent push if our app still open?
Are there any chat service that software industry used as standard
Try having a look at Firebase it has real time database and an FCM for your chat / push notification needs.
I have created an Push Notification application in IBM's Worklight in which it is sending notification for only one user's device(Android Device).How I can send Push notification to multiple user's devices?If any one created application then provide me some sample.
Worklight server must know user's identity in order to be able to send push notifications. In case you did not define any user authentication in your application, Worklight server will use an "anonymous" user identity - a persistent cookie created on first application launch. This is considered an unauthenticated access.
In case this is the model you want to use you need to declare an EventSource in your adapter which does not require authentication (do not specify securityTest for it) and then use WL.Server.notifyAll(eventSource, options) API.
This will send notification to users that are subscribed to a specified event source.
Source: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=462167&tstart=360
Push notification works on Android and iOS only.
You can see how to implement on iOS in the push notifications module.
You can find the module at https://www.ibm.com/developerworks/mobile/worklight/getting-started/index.html#advanced
What I did to accomplish this is to save in a backend database all the users subscribed to a specific event source then send notifications to each of them.
I checked the Worklight info center and WL.Server.notifyAll(eventSource, options) api is not listed!!