From 88b1cad8c4c2e776535fe5711c75dd992d6cbbaa Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Fri, 18 May 2018 08:26:16 +0100 Subject: [PATCH] [android][notifications] Change actions `runInBackground` to use `showUserInterface` instead --- .../DisplayNotificationTask.java | 8 ++++---- lib/index.d.ts | 7 ++++--- lib/modules/notifications/AndroidAction.js | 20 +------------------ lib/modules/notifications/types.js | 1 - 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java b/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java index e21073ee..acc178a0 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java +++ b/android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java @@ -294,11 +294,11 @@ public class DisplayNotificationTask extends AsyncTask { } private NotificationCompat.Action createAction(Bundle action, Class intentClass, Bundle notification) { - boolean runInBackground = action.containsKey("runInBackground") && action.getBoolean("runInBackground"); + boolean showUserInterface = action.containsKey("showUserInterface") && action.getBoolean("showUserInterface"); String actionKey = action.getString("action"); - PendingIntent actionIntent = runInBackground ? - createBroadcastIntent(notification, actionKey) : - createIntent(intentClass, notification, actionKey); + PendingIntent actionIntent = showUserInterface ? + createIntent(intentClass, notification, actionKey) : + createBroadcastIntent(notification, actionKey); int icon = getIcon(action.getString("icon")); String title = action.getString("title"); diff --git a/lib/index.d.ts b/lib/index.d.ts index ae41b750..364d28d4 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -832,7 +832,10 @@ declare module 'react-native-firebase' { EMAIL_LINK_SIGN_IN_METHOD: string; EMAIL_PASSWORD_SIGN_IN_METHOD: string; credential: (email: string, password: string) => AuthCredential; - credentialWithLink: (email: string, emailLink: string) => AuthCredential; + credentialWithLink: ( + email: string, + emailLink: string + ) => AuthCredential; }; interface Auth { @@ -1277,7 +1280,6 @@ declare module 'react-native-firebase' { semanticAction?: SemanticAction; showUserInterface?: boolean; title: string; - runInBackground?: boolean; constructor(action: string, icon: string, title: string); @@ -1285,7 +1287,6 @@ declare module 'react-native-firebase' { setAllowGenerateReplies(allowGeneratedReplies: boolean): Action; setSemanticAction(semanticAction: SemanticAction): Action; setShowUserInterface(showUserInterface: boolean): Action; - setRunInBackground(runInBackground: boolean): Action; } class RemoteInput { diff --git a/lib/modules/notifications/AndroidAction.js b/lib/modules/notifications/AndroidAction.js index c52f9c13..4eead513 100644 --- a/lib/modules/notifications/AndroidAction.js +++ b/lib/modules/notifications/AndroidAction.js @@ -16,12 +16,12 @@ export default class AndroidAction { _semanticAction: SemanticActionType | void; _showUserInterface: boolean | void; _title: string; - _runInBackground: boolean | void; constructor(action: string, icon: string, title: string) { this._action = action; this._icon = icon; this._remoteInputs = []; + this._showUserInterface = true; this._title = title; } @@ -53,10 +53,6 @@ export default class AndroidAction { return this._title; } - get runInBackground(): ?boolean { - return this._runInBackground; - } - /** * * @param remoteInput @@ -107,16 +103,6 @@ export default class AndroidAction { return this; } - /** - * - * @param runInBackground - * @returns {AndroidAction} - */ - setRunInBackground(runInBackground: boolean): AndroidAction { - this._runInBackground = runInBackground - return this; - } - build(): NativeAndroidAction { if (!this._action) { throw new Error('AndroidAction: Missing required `action` property'); @@ -134,7 +120,6 @@ export default class AndroidAction { semanticAction: this._semanticAction, showUserInterface: this._showUserInterface, title: this._title, - runInBackground: this._runInBackground }; } } @@ -161,9 +146,6 @@ export const fromNativeAndroidAction = ( if (nativeAction.showUserInterface) { action.setShowUserInterface(nativeAction.showUserInterface); } - if (nativeAction.runInBackground) { - action.setRunInBackground(nativeAction.runInBackground); - } return action; }; diff --git a/lib/modules/notifications/types.js b/lib/modules/notifications/types.js index c94cbd7b..780eabab 100644 --- a/lib/modules/notifications/types.js +++ b/lib/modules/notifications/types.js @@ -136,7 +136,6 @@ export type NativeAndroidAction = {| semanticAction?: SemanticActionType, showUserInterface?: boolean, title: string, - runInBackground?: boolean, |}; export type NativeAndroidNotification = {|