evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

Notification Json show in log but Notif. popup not showing on React-native (react-native-fcm) in Android #1039

Closed lovekothari123 closed 6 years ago

lovekothari123 commented 6 years ago

I have problem with notf. when i send a notif. from Firebase.console (https://console.firebase.google.com) Notification popup is come on navigation bar but when i send a notif. from my Admin panel it will only show a json.(In CMD) No popup no any icon show in navigation bar What Should i do for that Plz. Help me for that

I will also mention both Response Here 1) Response Come When I send A Notification From Firebase.console is that :-

notificationListener: ', { 'google.sent_time': 1536147796938, from: '710551289404', 'google.message_id': '0:1536147796942251%fcb84e0ffcb84e0f', collapse_key: 'com.reactapp', fcm: { action: null, tag: null, icon: null, color: null, body: 'on forground 2', title: null }, finish: [Function: finish] }

2) Response Come When I send A Notification From My Admin Penal is that 👎

notificationListener: ', { time_to_live: '4', show_in_foreground: 'true', fcm: {}, ProjectStageCommentId: '0', collapse_key: 'score_update', 'google.message_id': '0:1536147715902160%fcb84e0ff9fd7ecd', IsClosed: 'False', title: 'Statzi', 'google.sent_time': 1536147715898, sound: 'Enabled', volume: '3.21.15', score: '4x8', body: 'this is for testings by 123', icon: 'myicon', from: '710551289404', time: '05-09-2018 17:11:58', finish: [Function: finish] }

If any One Understand any problem so please help me for that

i will use a lib. npm react-native-fcm ?

For Message Show in forground I will use This code in App.js

componentDidMount(){ FCM.on(FCMEvent.Notification, notif => { // if (notif.fcm && notif.fcm.body) { / Create local notification for showing in a foreground / console.log(" success register fcm >> notificationListener: ", notif) // if (notif.local_notification) return; FCM.presentLocalNotification({ body: notif.fcm.body, priority: "high", title: notif.fcm.title, sound: "default", show_in_foreground: true, local_notification: true, auto_cancel:true, lights:true, "large_icon": "ic_launcher",// Android only icon: "ic_launcher", "show_in_foreground": true, / notification when app is in foreground (local & remote)/ vibrate: 300, / Android only default: 300, no vibration if you pass null/ "lights": true, // Android only, LED blinking (default false) status: "400" }); }) }

evollu commented 6 years ago

for Android you can use the following type of payload

{
  data:{
     custom_notification:{
         ...//title body etc
     }
  }
}