React-native-notifications: Android empty localNotification in release apk.

Created on 13 Mar 2020  路  11Comments  路  Source: wix/react-native-notifications

Hi!

I am using local notifications, everything works like charm in debug, but when I create the release apk , the notifications start to appear empty, no title, no body. Has anyone face the same issue?

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-notifications": "3.1.1",

Thanks in advance,

Most helpful comment

1- node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java

line 167 <> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
            CHANNEL_NAME,
            NotificationManager.IMPORTANCE_HIGH); --> importance_default channge to IMPORTANCE_HIGH to show notifications

    final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.createNotificationChannel(channel);
    notification.setChannelId(CHANNEL_ID);
}

<>

2- TO show notification TEXT comment the react-native notifications manifest aplication. node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml

komentatu aplication barruan dagoen guztia

coment all in
application <>

<!--
 A proxy-service that gives the library an opportunity to do some work before launching/resuming the actual application task.

<service android:name=".core.ProxyService"/>

<service
    android:name=".fcm.FcmInstanceIdListenerService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>

<service
    android:name=".fcm.FcmInstanceIdRefreshHandlerService"
    android:exported="false" /> -->


/application

All 11 comments

I have same problem! On release apk notification is show without text. On debug notification is show good.
image

Same issue here... with

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-notifications": "3.1.2"

1- node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java

line 167 <> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
            CHANNEL_NAME,
            NotificationManager.IMPORTANCE_HIGH); --> importance_default channge to IMPORTANCE_HIGH to show notifications

    final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.createNotificationChannel(channel);
    notification.setChannelId(CHANNEL_ID);
}

<>

2- TO show notification TEXT comment the react-native notifications manifest aplication. node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml

komentatu aplication barruan dagoen guztia

coment all in
application <>

<!--
 A proxy-service that gives the library an opportunity to do some work before launching/resuming the actual application task.

<service android:name=".core.ProxyService"/>

<service
    android:name=".fcm.FcmInstanceIdListenerService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>

<service
    android:name=".fcm.FcmInstanceIdRefreshHandlerService"
    android:exported="false" /> -->


/application

Same issue here... with

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-notifications": "3.1.2"

We solvet with this
https://github.com/wix/react-native-notifications/issues/531#issuecomment-599628247

Hi @jsbeckr !
Our problem, same as @ArkaitzSKR , was that we were using @react-native-firebase/messagging for receiving the data messages. For some reason, in debug mode there was no problem, but after making the release version it seems like only "react-native-notifications" was receiving the messages. So that, we comment every service inside AndroidManifest.xml inside "react-native-notifications" library, maked apk again , and it started working. As @ArkaitzSKR mentioned in https://github.com/wix/react-native-notifications/issues/531#issuecomment-599628247 (look to the point 2 for your problem).

Hope it helps.

Hi @jsbeckr !
Our problem, same as @ArkaitzSKR , was that we were using @react-native-firebase/messagging for receiving the data messages. For some reason, in debug mode there was no problem, but after making the release version it seems like only "react-native-notifications" was receiving the messages. So that, we comment every service inside AndroidManifest.xml inside "react-native-notifications" library, maked apk again , and it started working. As @ArkaitzSKR mentioned in #531 (comment) (look to the point 2 for your problem).

Hope it helps.

Where else did you register the intent-filter then?

Hi,

in the end we decided against this lib and implemented it ourselves with native modules. In the end we wrote maybe 50 lines of Java code and have all the functionality we need.

I sadly can鈥檛 recommend this library in the current state.

Hi,

in the end we decided against this lib and implemented it ourselves with native modules. In the end we wrote maybe 50 lines of Java code and have all the functionality we need.

I sadly can鈥檛 recommend this library in the current state.

Yeah it is a bit messy right now. I got it to work by fixing some of the native code and patching the package. I've created a patch to get foreground notifications to work on Android, maybe it will help some people:

https://gist.github.com/monotv/d6a064a1af27524c520689ada5ffe29f

Hi @monotv
I undertant that you got it to work didn't you?
I think that the problem with priority should be included in this library as a new functionality, I mean you should be able to estabilsh dinamically the priority of a notification.
The problem with manifest is not really a library problem, as I understood is more a compatibility problem with @react-native-firebase/messaging. Anyway this would be very common so it would be great to explain it in documentation.

Anyway this would be very common so it would be great to explain it in documentation.

I mean yeah, people will probably use this together with @react-native-firebase/messaging quite a lot so I agree.

I use Firebase FCM. What worked for me was to comment those lines in node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml :

<-- <service
    android:name=".fcm.FcmInstanceIdListenerService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>

<service
    android:name=".fcm.FcmInstanceIdRefreshHandlerService"
    android:exported="false" /> -->

And I agree with a previous poster : This library is a dumpster. Wix should be ashamed.

Was this page helpful?
0 / 5 - 0 ratings