使用XMPP在Android中用户离线时向用户发送通知 [英] Sending Notification to user when user is offline in android using XMPP

查看:136
本文介绍了使用XMPP在Android中用户离线时向用户发送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Smack客户端和XMPP服务器实现了一个Android聊天应用程序.当用户在线时,现在用户离线(应用程序未处于运行状态)时,一切正常.我想使用GCM推送通知.

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?

推荐答案

我也面临着这个问题.我正在按照以下步骤解决这个问题:

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

  1. 使用包含每个JID用户FCM-TOKENS的数据库开发WebService(ASP或PHP或...)
  2. 在Android设备上开发FCM,并在刷新后将令牌发送到我的WebService并将其保存在数据库中.
  3. 在openfire中激活"CallBackOnOffline"插件. (当收到消息但收件人不可用时,它将带有JSON的POST请求发送到已定义的网址)
  4. 将服务属性"中的"plugin.callback_on_offline.url"设置为我的WebService.因此,消息和消息将发送到我的Web服务.
  5. 现在从我的Web服务数据库中获取FCM-TOKEN,并将包含消息正文和标题的请求发送到FCM.

这篇关于使用XMPP在Android中用户离线时向用户发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆