invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

🔥 Error setting AndroidNotification "setRemoteInputHistory" #2676

Closed rimzici closed 5 years ago

rimzici commented 5 years ago

Issue

Getting error while setting setRemoteInputHistory.

Here is a sample usage:

const notificationDef = new firebase.notifications.Notification()
        .setNotificationId(id)
        .setTitle(title)
        .setData(data)
        .setSubtitle(subtitle)
        .setBody(body);

    const action = new firebase.notifications.Android.Action(SEC_CHAT_REPLY_ACTION, 'ic_launcher', 'Reply');
    action.setShowUserInterface(false);
    const resKey = new firebase.notifications.Android.RemoteInput(SEC_CHAT_RESULT_KEY);
    action.addRemoteInput(resKey);

notificationDef
        .android.setSmallIcon('ic_launcher')
        .android.setBigText(body)
        .android.setAutoCancel(true)
        .android.setChannelId(CHANNEL_ID)
        .android.setTag('tag')
        .android.setGroup(groupId)
        .android.addAction(action)
        .android.setPriority(firebase.notifications.Android.Priority.High)
        .android.setRemoteInputHistory(['history'])
        .android.setGroupAlertBehaviour(firebase.notifications.Android.GroupAlert.Children);

The error at the java realm:

java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String[]
        at android.os.BaseBundle.getStringArray(BaseBundle.java:1509)
        at io.invertase.firebase.notifications.DisplayNotificationTask.doInBackground(DisplayNotificationTask.java:288)
        at io.invertase.firebase.notifications.DisplayNotificationTask.doInBackground(DisplayNotificationTask.java:32)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

In the docs the data type of remoteInputHistory is mentioned as Array. But the native module seem to expect String[], and the java equivalent of JS Array is ReadableArray.


Project Files

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [x] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz Memory: 20.23 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.4.0 - /usr/local/bin/node Yarn: 1.17.0 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.0 System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.4 => 0.60.4 npmGlobalPackages: react-native-cli: 2.0.1 react-native-create-library: 3.1.2 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [] Android - [ ] **iOS** but have not tested behavior on Android - [X] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `^5.5.6` - **`Firebase` module(s) you're using that has the issue:** - `Notification` - **Are you using `TypeScript`?** - `N`


Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

stale[bot] commented 5 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.