简体   繁体   中英

Using push notifications to trigger code within Android app?

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.

我的建议是使用FireBase ...,并使您的Json标签使用“数据”而不是“通知”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM