Sending Notification to user when user is offline in android using XMPP

倖福魔咒の 提交于 2020-01-13 12:05:49

问题


I implemented an Android chat application using Smack client with XMPP server. Everything works fine when the user is online, now when the user is offline (the app is not in running state). I would like to push notification using GCM.

Is there a way to achieve that, and is there a way that we can manage our server itself to take care of that?


回答1:


You can send push notification any time the user is online or not but the device has internet.You have all devices device tokens so when you send a message to a particular user, use his device token and send push notification.




回答2:


I'm facing this problem too.I'm solving this as folowing steps:

  1. Develope a WebService (ASP or PHP or ...) with a database that will contains users FCM-TOKENS per JID
  2. Developing FCM on android devices and send TOKEN whent it refreshed to my WebService and save it in db.
  3. Activate "CallBackOnOffline" plugin in openfire. (that sends POST request with a JSON to defined url when a message received but recipient is UnAvailable)
  4. Set "plugin.callback_on_offline.url" in "Service Properties" to my WebService. So the message and the jid will be sent to my web service.
  5. Now fetch the FCM-TOKEN from my web service db and send a request to FCM containing message body and title.


来源:https://stackoverflow.com/questions/37433741/sending-notification-to-user-when-user-is-offline-in-android-using-xmpp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!