0

Is it possible to send a push notification to a user after they have left an android app for a defined period of time?

4

1 に答える 1

0

はい、もちろん!

Android を GcmBroadcastReceiver クラスに登録する必要があります。そして許可を追加します

クラスは、プッシュ メッセージがいつ到着したかを通知し、アプリ内のクラスによって処理されます。

次に例を示します。

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);
    }

}
于 2014-06-16T20:19:53.843 に答える