evollu / evollu/react-native-fcm
Local notifications does not work on Android 7.0 if there is no mipmap/ic_launcher or drawable/ic_launcher resource or if icon resource is not named specifically in payload
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 661
- PR merge metrics
- No merged PRs in 30d
Description
_> What version of RN and react-native-fcm are you running?_
react-native: 0.51.0
react-native-fcm: 11.3.1
_> What device are you using? (e.g iOS9 emulator, Android 6 device)?_
Xiaomi Mi 5 with Android 7.0
_> Is your app running in foreground, background or not running?_
Problem occurs regardless of app state.
I've encountered very strange problem when foreign notifications worked fine but local notifications were not displayed. Notifications from firebase console showed up in notification bar without a hitch, but `FCM.presentLocalNotification({...})` with payload from [example](https://github.com/evollu/react-native-fcm/blob/0d0b0eaeb96f661161aeac0dc328b6d5e8453d21/Examples/simple-fcm-client/app/App.js#L61-L72) did nothing. App from examples worked fine, but my app with the same javascript didn't.
Logs from `adb logcat` showed this message:
```
01-29 18:44:25.732 25466 25491 E ReactNative: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=1 contentView=null vibrate=[0,500] sound=null defaults=0x0 flags=0x10 color=0x00000000 category=call vis=PRIVATE)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.app.NotificationManager.notifyAsUser(NotificationManager.java:306)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.app.NotificationManager.notify(NotificationManager.java:284)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.support.v4.app.NotificationManagerCompat$ImplBase.postNotification(NotificationManagerCompat.java:179)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.support.v4.app.NotificationManagerCompat.notify(NotificationManagerCompat.java:290)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.support.v4.app.NotificationManagerCompat.notify(NotificationManagerCompat.java:274)
01-29 18:44:25.732 25466 25491 E ReactNative: at com.evollu.react.fcm.SendNotificationTask.doInBackground(SendNotificationTask.java:217)
01-29 18:44:25.732 25466 25491 E ReactNative: at com.evollu.react.fcm.SendNotificationTask.doInBackground(SendNotificationTask.java:31)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.os.AsyncTask$2.call(AsyncTask.java:304)
01-29 18:44:25.732 25466 25491 E ReactNative: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-29 18:44:25.732 25466 25491 E ReactNative: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
01-29 18:44:25.732 25466 25491 E ReactNative: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
01-29 18:44:25.732 25466 25491 E ReactNative: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
01-29 18:44:25.732 25466 25491 E ReactNative: at java.lang.Thread.run(Thread.java:760)
```
I've tried various icon fields in payload - nothing worked. Setting ["com.google.firebase.messaging.default_notification_icon"](https://github.com/evollu/react-native-fcm/tree/0d0b0eaeb96f661161aeac0dc328b6d5e8453d21#android) also didn't help.
Then I copied all mipmap directories from example and it did the trick. But notifications had my app's normal icon, not the one from example app (maybe it's just that MiUI does not support custom icons, example app also has balloon-icon, not exclamation-point-icon).
My app's icon is located at `@drawable/icon` and AndroidManifest.xml points to it in `android:icon` field.
Then I deleted files copied from example app and added `icon: 'icon'` to payload and it worked also. [And why wouldn't it?](https://github.com/evollu/react-native-fcm/blob/0d0b0eaeb96f661161aeac0dc328b6d5e8453d21/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java#L102-L106).
I'm new to mobile development so I'm not sure is it me at fault or should this library handle such cases. Anyway, I've created this issue to help anybody who will encounter the same problem I did.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.