V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
sherlocktheplant
V2EX  ›  问与答

iOS 上的 IM 用怎样的方案比较好?

  •  
  •   sherlocktheplant · 2015-10-13 17:36:12 +08:00 · 2501 次点击
    这是一个创建于 3122 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我们公司现在做自己开发应用内的 IM 系统 android 方面已经开发完成 服务器是 mqtt 协议 数据格式为自己定义的 JSON 格式 有一个随机启动的后台服务和 Activity 交互
    但是 iOS 比较麻烦 不能跑后台进程 我也不愿意用“无限循环播放空音频”这么 low 的手段

    那么我能想到的方案只有两种:
    1. 全部改用 Apple Push Notification Service 或者 PushKit (因为我们有语音通话 VOIP 功能)
    2. 应用处于后台时使用 Apple Push Notification Service 或者 PushKit
    应用处于前台时使用 MQTT 协议

    请问一下各位觉得那种好一点 为什么 或者有没有更好的方案?
    7 条回复    2015-11-02 10:18:57 +08:00
    sherlocktheplant
        1
    sherlocktheplant  
    OP
       2015-10-13 18:03:49 +08:00
    吃饭去了 回来再看看有人回复没有
    hging
        2
    hging  
       2015-10-13 18:06:41 +08:00
    全部改 apple push 吧. 这样统一. 要不你还要判断客户端是不是在线- -
    sherlocktheplant
        3
    sherlocktheplant  
    OP
       2015-10-13 20:20:54 +08:00
    @hging
    mqtt 自带是有心跳协议的 但是推送的话就没有 但是如果不能跑后台服务 我也不知道怎么传心跳了
    hging
        4
    hging  
       2015-10-14 10:55:47 +08:00
    @sherlocktheplant 不能跑后台心跳就断了么. 就当做离线了. 然后用 Apple 的推送就行. 有心跳就在线. 就走 MQTT
    sherlocktheplant
        5
    sherlocktheplant  
    OP
       2015-10-14 11:04:07 +08:00
    @hging 那个确实没有办法 不知道 qq 是怎么实现的在线状态的问题 微信没有在线状态 所以不存在这个问题 不过我们的 im 也并没有在线状态的要求
    hging
        6
    hging  
       2015-10-14 11:17:05 +08:00
    @sherlocktheplant 就是你程序在线肯定就有 MQTT 发心跳嘛 你服务器端检测这个心跳 然后如果某个用户突然没心跳就证明客户端离线 然后就调用 Apple 的推送推送提醒 然后打开客户端不就又有心跳了- -
    xmliu
        7
    xmliu  
       2015-11-02 10:18:57 +08:00
    太折腾了,推荐楼主使用 IM 云服务
    利益相关者:@网易云信
    哈哈哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2262 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:15 · PVG 12:15 · LAX 21:15 · JFK 00:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.