diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-02-16 01:24:12 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-02-16 01:24:12 +0100 |
| commit | 30c49550c89c1b69c680170d2dc247eac76bd463 (patch) | |
| tree | 8732652298b630b9ba15def97e59738f1c9bf7b6 /StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java | |
| parent | 8f1f626384e6ba75f4fb24c27e0973260a74421b (diff) | |
push plugin
Diffstat (limited to 'StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java')
| -rw-r--r-- | StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java new file mode 100644 index 00000000..3ccea6cb --- /dev/null +++ b/StoneIsland/plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.java @@ -0,0 +1,41 @@ +package com.adobe.phonegap.push; + +import android.app.NotificationManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.support.v4.app.RemoteInput; + +public class BackgroundActionButtonHandler extends BroadcastReceiver implements PushConstants { + private static String LOG_TAG = "PushPlugin_BackgroundActionButtonHandler"; + + @Override + public void onReceive(Context context, Intent intent) { + Bundle extras = intent.getExtras(); + Log.d(LOG_TAG, "BackgroundActionButtonHandler = " + extras); + + int notId = intent.getIntExtra(NOT_ID, 0); + Log.d(LOG_TAG, "not id = " + notId); + NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancel(GCMIntentService.getAppName(context), notId); + + if (extras != null) { + Bundle originalExtras = extras.getBundle(PUSH_BUNDLE); + + originalExtras.putBoolean(FOREGROUND, false); + originalExtras.putBoolean(COLDSTART, false); + originalExtras.putString(ACTION_CALLBACK, extras.getString(CALLBACK)); + + Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); + if (remoteInput != null) { + String inputString = remoteInput.getCharSequence(INLINE_REPLY).toString(); + Log.d(LOG_TAG, "response: " + inputString); + originalExtras.putString(INLINE_REPLY, inputString); + } + + PushPlugin.sendExtras(originalExtras); + } + } +} |
