Closed anish000kumar closed 5 years ago
works for me?
{"to":"", "content_available":true,
"data": {
"custom_notification": {
"title": "title",
"body": "body",
"picture": "https://files.allaboutbirds.net/wp-content/uploads/2015/06/prow-featured.jpg"
}
},
"priority": "high"
}
@evollu I tried using same payload like you did but still did not get the picture show. did I did something wrong in this case. here is screenshot and message
This is what I received..
`{ "to" : "", "content_available":true, "data": { "custom_notification": { "title": "title", "body": "body", "picture": "https://files.allaboutbirds.net/wp-content/uploads/2015/06/prow-featured.jpg" } }, "priority": "high"
}`
showLocalNotification(notif) { console.log('here local', notif) FCM.presentLocalNotification({ title: notif.title, body: notif.body, priority: "high", click_action: notif.click_action, show_in_foreground: true, local: true }); }
thanks @evollu , it's working.. Initially Im using fcm@6 .. but now 15.0.2 👍
@anish000kumar is your issue resolved?
I want to get a notification sent from firebase console with an image. i successfully get simple text notifications. anyone help me..
this is my code: async componentDidMount() { this.checkPermission(); this.createNotificationListeners(); }
//1 async checkPermission() { const enabled = await firebase.messaging().hasPermission(); if (enabled) { this.getToken(); } else { this.requestPermission(); } }
//3 async getToken() { let fcmToken = await AsyncStorage.getItem('fcmToken'); if (!fcmToken) { fcmToken = await firebase.messaging().getToken(); if (fcmToken) { // user has a device token await AsyncStorage.setItem('fcmToken', fcmToken); } } }
//2 async requestPermission() { try { await firebase.messaging().requestPermission(); // User has authorised this.getToken(); } catch (error) { // User has rejected permissions console.log('permission rejected'); } }
componentWillUnmount() { this.notificationListener(); this.notificationOpenedListener(); }
async createNotificationListeners() { /*
*/ this.notificationListener = firebase.notifications().onNotification((notification) => { const { title, body } = notification; this.showAlert(title, body); });
/*
*/ this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen) => { const { title, body } = notificationOpen.notification; this.showAlert(title, body); });
/*
showAlert(title, body) { Alert.alert( title, body, [ { text: 'OK', onPress: () => console.log('OK Pressed') }, ], { cancelable: false }, ); }
@evollu its not working when app is closed
@mack97 Are you not getting just the big picture notification or any notification when the app is closed? Cause if you're not getting any, then it's the Android battery saving functionality preventing the notification delivery. You'll have to turn off battery optimization for that app in Android's settings.
Info
RN version: 0.50.3 react-native-fcm version: 14.2.0 Emulator: Android Google Nexus 5x 7.1.0 API 25
Issue
I am trying to send big picture notification for Android, going through the docs I realized I need to setup
custom_notification
attribute to achieve so, which internally creates a local notification.So, the notification object sent from API now contains something like this:
notification
key has been removed from the object, as per the docs. But now empty notification is received. Also, if it helps, I am using react-native-splash-screen for implementing custom splashscreen as well.