简体   繁体   中英

Do I need to use GCM to make an android app that can be updated?

I made an android app but I want to be able to update certain values even after the client has the app running(let's say I've got x=5; in the code and in the new version I'd like to have x=10; instead), kind of like how the apps you download from the play store notify you of updates and you can install the latest version.

I can't see how this is possible while the app is installed locally on the mobile so I thought about the cloud solution. Is there another way to do it ? And how do apps like facebook and messenger send notifications to the user?

Assuming that you are talking about changing values, ie state of the app and not actually trying to download new code, you have a couple of options.

If this is the case then what you really want to do is to make your app aware that something needs to change. (This could be just a notification that there is a new version and that the user should download it from the play store)

There are a least two ways to the information to your app.

GCM is one option, but not the only option.

GCM is for "push" notifications, ie notifications that you want to send your app or user even if they are currently using your app. In order to use GCM you would need to host some sort of a server, which would send the notification when the server deems it is needed.

An other option would be to have your app "check in" with your server and download some content. The content could contain the values that need to be changed, or simply that the app should inform the user that he/she should take some further action to update something with respect to the app. This also would require that you host a server.

The second option is easier, mainly because in order to send your app messages via GCM, you pretty much have to be able to do the second option. The android platform provides many life cycle hooks which give you opportunities to "check in" with your server. For example during the onResume of an Activity might be a good place to "check in"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM