当后端更改需要更新的应用程序时如何强制更新应用程序
我已经阅读了有关强制更新应用程序的不同帖子,并且 ppl 的唯一想法(据我所知)是创建一个 Web 服务,该应用程序调用该服务以查看当前版本是什么.WS 必须手动更新它们以反映版本代码.
I have read different posts about forcing an update of an app, and the only idea that ppl has had (as far as I can tell) is to create a web service which the app calls to see what version is the current one. The WS must them manually be updated to reflect the versionCode.
这种方法有几个问题:
问题一:
当您将应用上传到 Play 商店时,它需要 几个小时 才能供设备下载,而您永远不知道什么时候.此外,在我看来,它似乎在不同的时间适用于不同的设备,所以你真的不知道什么时候它适用于所有人".
When you upload an app to the Play Store, then it takes several hours before it is available for devices to download, and you never know when. Also, it seems to me like it becomes available at different times for different devices, so you really have no clue what so ever when its "available for all".
这意味着您不能立即更新 WS(告诉应用程序当前"版本是什么),因为将它们引导到 Play 商店不会很有建设性,因为更新后的应用程序无论如何都不可用.而且由于你不知道它什么时候可用,你也不知道什么时候更新 WS.
This means that you cannot immediately update the WS (that tells the app what is the "current" version) since directing them to Play Store won't be very constructive, as the updated app isn't available there anyways. And since you don't know when it will be available, you don't really know when to update the WS.
问题 2:
有时您会对后端进行一些更改(通信协议更改或其他),这需要您上传新版本的应用程序,然后更新后端,以便它们可以按预期相互通信.在这种情况下,您确实需要某种方式告诉应用请更新,因为您已经过时了"并将它们引导到 Play 商店.
Sometimes you do some changes to the back-end (comm protocol changes or something else) that requires you to upload the new version of the app and then update the backend so that they can talk to each other as expected. In this case, you really want some way to tell the app that "please update since you are out of date" and direct them to the Play Store.
那么,问题来了,我该如何实现这个功能呢?
So, the question is, how can I achieve this functionality?
推荐答案
正如 zapl 所说,后端应该始终允许向后兼容.每当您的应用调用后端服务器时,应用应报告其版本号,并且后端应做出相应响应.
As zapl has commented, the backend should ALWAYS allow backward compatibility. Whenever your app makes a call to the backend server the app should report its version number and the backend should respond accordingly.
至于强制应用更新,您应该查看 GCM 以推送通知,然后将用户带到更新,尽管实际上这不会强制"用户更新.
As for forcing an app update, you should look at GCM to push a notification which will then take the user to the update although in reality this wouldn't actually 'force' the user to update.
无论哪种方式,只要后端和应用程序都相互报告它们的版本号(可能带有更新可用"的通知),那么您就可以这样设计 1).他们继续工作,2).用户将在需要时尽快更新.
Either way, as long as both the backend and app report their version numbers to each other (perhaps with a notification of 'update available') then you can design things so 1). they continue to work and 2). users will update ASAP when they need to.
我了解发布到 Google Play 可能会有所延迟,但只要后端保持向后兼容性,这应该不是问题.
I understand that publishing to Google Play can have delays but as long as the backend retains backward compatibility, it shouldn't be a problem.
相关文章