将光标移到/点击文章中的句子上,可以查看译文。      显示繁体中文内容    显示简体中文内容

Android Push Notifications or a Service?
Android推送通知或者服务?

0 0

I have an app which runs on iPhone and Android devices. i also have a server that transfers files and other data between the clients. Now, my question is about the android client.

Currently, i have a service that runs in the background and handles the output and input, to and from the server, and whenever a new data recieved from the server, the client will launch a notification to the user.

So, if the user go in to his device Setting and force to close the app, the service stops running and the data won't be recieved (the socket to the server will close and the server won't send him any data and will store it in the database for the next time the user launchs the app and connects).

So this is one approach, but another on is the Push Notifications, that will launch a notification even if the entire app including the service, is closed. but the downside is, the way i see it, that i need to use a 3rd party component in my app and it increases the complexity.

I need help to decide whether or not to use the Push Notification, and also, how common is this feature in other Android apps?

时间: 原作者:

0 0

as far as i understood you have a service always running with a socket connection always connected to your server. that is a HUGE battery consumption and probably is already a lot of unnecessary complication to your app.

the 3rd party component you're talking about is the Google Play Service, which is developed and maintained by the same people who created the Android OS (that's Google).

The"extra complication"you're talking about is to add a couple of permissions and a BroadcastReceiver on the AndroidManifest.xml and register your application on the GCM web-panel. which is all detailed here https://developer.android.com/google/gcm/client.html

It's a very VERY very VERY very common thing in lots of apps. Facebook, Facebook messenger, Gmail, Weather apps with severe weather notification, WhatsApp, Skype, Twitter, pretty much anything with a"what's new"section, Foursquare. all of them uses push notification.

So to answer the question in a very direct way :

  • you definitely should use the Push notification.
原作者:
...