mysql - Android Notification: GCM or Service -
i notify (create notification) user whenever receives in-app request.
i'm using mysql database php - regular stuff.
whenever value of user_id_req field changes 0 1, app should create notification. able on app start notificationmanager
, checking db in real-time, meaning value changes.
should use gcm handle requests or service runs in background , checks database every minute?
you should absolutely use gcm this, rather polling model.
it bad practice make network request every minute - lead significant battery usage. moreover, unless have service hold wake-lock (which really kill battery), device go sleep , requests stop until user wakes device again. issue unless register app wake , trigger service on boot, polling stop whenever user restarts device.
it happens gcm tutorials have create service
. don't let confuse you. if you're showing notification user, don't need service
, simple broadcastreceiver
work fine.
Comments
Post a Comment