Is it possible to send a push notification to a user after they have left an android app for a defined period of time?
Asked
Active
Viewed 886 times
0
-
what research have you done so far? – panini Jun 16 '14 at 20:17
-
depends on if the key is still valid for that user – tyczj Jun 16 '14 at 20:17
1 Answers
0
Yes of course!
You should suscribe your android to your GcmBroadcastReceiver class. and add the permission
Your class will tell when a push message arrives, and be handled by your class in your app.
Here is an example:
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}

Nacho
- 2,057
- 2
- 23
- 32
-
Hey, thanks for the response. I'm pretty new to Android development so please forgive my ignorance. What do you mean by subscribe your android to your GcmBroadcastReceiver class? – Cobi Jun 17 '14 at 14:21
-
i asume you are using GCM yo implement the push service...here you can find how to implement it. You will se, you have the GcmBroadcastReciever. https://developer.android.com/google/gcm/client.html – Nacho Jun 18 '14 at 01:01