I used third party push service in my application, when a message is push from server, it's background service will send a broadcast which I have to listen to, this process just works fine. In the function onReceive() ,I can either show notification or just do some work silently. Whether show notification or not will depend on the app status, that is:
if(application_is_running){
if(message_type == chat_message){
if(chat_activity_is_present){
/** notification not allowed **/
}else{
/** show notification, open the corresponding chat activity on clicking the notification */
}
}else{
/** store the message silently **/
}
}else{
/** show notification, and start the app on clicking the notification**/
}
What is the best practice to inform my application when the broadcast receiver gets the push message from server?
--EDIT--
By best practice, I mean the best way to send the message(without changing the message handling logic in my app) to my application to deal with.
This could help.
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.