V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
sherlocktheplant
V2EX  ›  问与答

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

  •  
  •   sherlocktheplant · Oct 13, 2015 · 3362 views
    This topic created in 3857 days ago, the information mentioned may be changed or developed.
    我们公司现在做自己开发应用内的 IM 系统 android 方面已经开发完成 服务器是 mqtt 协议 数据格式为自己定义的 JSON 格式 有一个随机启动的后台服务和 Activity 交互
    但是 iOS 比较麻烦 不能跑后台进程 我也不愿意用“无限循环播放空音频”这么 low 的手段

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

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