Reputation: 11
Hi everyone
I use library wix/react-native-notifications
It looks like I do something wrong with my android (ios works fine). For me:
work good.
But:
have never triggered.
I think I put something wrong in AndroidManifest.xml (I have tried different variant but it still doesn't work).
Or problem occurs from using
at the same time.
Please maybe someone have some ideas?
I use:
Part of AndroidManifest.xml that I think can be wrong:
<service
android:name=".java.MyFirebaseMessagingService"
android:exported="false"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Upvotes: 0
Views: 1345
Reputation: 1222
You can receive Push Notification on foreground in react native in this way
import {firebase} from '@react-native-firebase/messaging'
import PushNotification from "react-native-push-notification";
useEffect(()=>{notification()},[])
const notification = () => {
const messaging=firebase.messaging;
const unsubscribe = messaging().onMessage(async remoteMessage => {
console.log('A new FCM message arrived!', JSON.stringify(remoteMessage));
PushNotification.localNotification({
channelId: "reminder",
message: remoteMessage.notification.body,
title: remoteMessage.notification.title,
bigPictureUrl: remoteMessage.notification.android.imageUrl,
smallIcon: remoteMessage.notification.android.imageUrl,
});
});
return unsubscribe;
}
Upvotes: 2
Reputation: 11
Ok, maybe it will be helpful for someone or just start some discussions )
Well, from my understanding the react-native-pusher-push-notifications
handle notification first, so library react-native-notifications
can't catch that.
Not the better decision but it will works before I find better solution.
I modified file PusherWrapper.java
in react-native-pusher-push-notifications
library to handle more information. The main problem was that library doesn't return info that send in data
part of notification.
Upvotes: 0