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

怎么处理 deviceToken 和服务器端的同步?

  •  
  •   tsinghan · Dec 6, 2015 · 3402 views
    This topic created in 3802 days ago, the information mentioned may be changed or developed.

    像微信, qq 这种应用,怎么处理 deviceToken 和服务器端的同步?
    1 登录的时候 需要把用户信息和 deviceToken 一起发给后端?
    2 退出登录的时候,通知后端清楚 deviceToken ?但是在没网络连接的情况下,也能正常退出登录,这时候怎么同步?

    5 replies    2015-12-08 18:53:22 +08:00
    alloyapple
        1
    alloyapple  
       Dec 7, 2015
    为什么要通知后端清除?如果非要清除,在程序切换到后台是不是就要发清除指令。极端点,是不是得让服务器做超时操作?
    tsinghan
        2
    tsinghan  
    OP
       Dec 7, 2015
    @alloyapple 这种应用 好像是通过心跳来判断 客户端是否登录状态吧,然后来决定是否发通知
    c742435
        3
    c742435  
       Dec 7, 2015
    把 deviceToken 想成 cookie 你就明白了。
    浏览器单方面清 cookie 就解除登陆状态了
    lawder
        4
    lawder  
       Dec 8, 2015
    @alloyapple
    @c742435 后端不清除的话,帐户退出登录了,还继续收到跟帐号相关的推送,不合理吧?

    我的建议是没网络连接的情况下不能正常退出登录
    alloyapple
        5
    alloyapple  
       Dec 8, 2015
    @lawder 都没网络了,收不到推送了。服务器直接超时检测下就行了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2671 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 12:01 · PVG 20:01 · LAX 05:01 · JFK 08:01
    ♥ Do have faith in what you're doing.