Open alexey-m-ukolov opened 6 years ago
"com.google.firebase.messaging.default_notification_icon" is only for remote notification created be firebase SDK. local notification is not.
what is your icon file name in @drawable/icon
"com.google.firebase.messaging.default_notification_icon" is only for remote notification created be firebase SDK. local notification is not.
Well, it's in a Setup Local Notifications section of the docs, so - easy mistake to make.
what is your icon file name in @drawable/icon
It's drawable-*dpi/icon.png
.
Is android:icon
field from AndroidManifest.xml
accessible inside java classes? If so, maybe it should be the default value for small icon.
For reference:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/icon"
android:theme="@style/AppTheme"
>
...
</application>
</manifest>
android:icon="@drawable/icon"
is for app icon, not notification.
You need to specify it in your payload for local notification.
I've updated the misleading readme by the way
Yes, if I want custom icon I should specify it manually. But this library uses app icon (ic_launcher) as a fallback. But app icon could be named differently and then local notifications break completely and silently - that is the problem I've encountered. So, my proposal is to use icon specified in AndroidManifest.xml as a fallback and not rely on a hardcoded value of ic_launcher (if it's at all possible).
> 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 did nothing. App from examples worked fine, but my app with the same javascript didn't.Logs from
adb logcat
showed this message:I've tried various icon fields in payload - nothing worked. Setting "com.google.firebase.messaging.default_notification_icon" 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 inandroid: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?.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.