I am trying to implement the notification which working fine only facing one issue that when I want to show icon only with data it will show as an image.
The Library I am using is react-native-push-notification
For example, I want to show like this but it shows large image too on click of an arrow button.
Right now it is like this
That is how I want.
Here is my AndroidManifest.xml
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_notification"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
While on server side
$notification = array('content-available' => true, 'mutable-content' => true, 'title' => $title, 'text' => $body, 'icon' => $icon, 'sound' => 'default', 'badge' => '1');
If I pass icon then nothing will show if I use image then icon show but with the big image too.
My code is as below
import PushNotification from "react-native-push-notification";
import { PushNotificationIOS } from "react-native";
import { NavigationActions, StackActions } from "react-navigation";
import {ToastAndroid} from 'react-native';
const localNotification = data => {
console.log("const localNotification" + JSON.stringify(data));
if (data) PushNotification.localNotification(data);
return null;
};
let getToken;
const setToken = token => (getToken = token.token);
const configure = () => {
PushNotification.configure({
onRegister: setToken,
// largeIcon: "https://stag2.com/uploads/qr/407xg1.png",
// smallIcon: "ic_notification",
// ongoing: true,
onNotification(notification) {
onNotification(notification);
},
senderID: "5545454654654654",
// SmallIcon:"ic_notification",
permissions: {
alert: true,
badge: true,
sound: true
},
popInitialNotification: true,
requestPermissions: true
});
};
let onNotification = (notification) => {
notification.android.setSmallIcon('ic_notification')
// if (!!notification.title && !!notification.body) {
// PushNotification.localNotification({
// title: notification.title,
// message:"urfusion",
// });
// }
};
export { configure, localNotification, getToken };
I got what I wanted if I push local notification which called when the app opens on notification click event but I want on remote push notification not on local one.
let onNotification = (notification) => {
notification.android.setSmallIcon('ic_notification')
// if (!!notification.title && !!notification.body) {
PushNotification.localNotification({
title: notification.title,
message:"urfusion",
});
}
};