简体   繁体   中英

What is the correct and most memory efficient way to send notifications while in background?

I'm building a chat app and I noticed that when I wanted to build notifications, I saw that Slack doesn't use a Service to push notifications while in the background.

I was just curious if it's possible to push notifications without using a Service and if it's more efficient or less time consuming than using a Service .

Are you wanting to send a notification when something happens, like a chat message is received? If so, and if that event sends a system-wide broadcast, then you should register a BroadcastReceiver to listen for it and build your notification whenever it sees the event is broadcast. You can also schedule timed notifications this way.

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