i am trying to receive push notification data
here is code to send push notification to .FCM
> const message = {
> to: token,
> sound: 'default',
> priority: 'normal',
> data: {
> title: "π§ You've got mail",
> message: 'Hello world! π',
> data: { someData: 'goes here',page:'1' },
> experienceId: 'useraccount/appslug',
> scopeKey: 'useraccount/appslug',
> subtitle :"test sub title...",
> },
> };
> //await fetch('https://exp.host/--/api/v2/push/send', {
> await fetch('https://fcm.googleapis.com/fcm/send', {
> method: 'POST',
> headers: {
> 'Content-Type': 'application/json',
> Authorization: `key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
> },
> body: JSON.stringify(message),
> });
> }
i want to receive push notification details
here is code to receive details code
> useEffect(() => {
> registerForPushNotificationsAsync().then(token => { sendPushNotification(token); setExpoPushToken(token);alert(token, 'expoPushToken'); });
>
> // This listener is fired whenever a notification is received while the app is foregrounded
> notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
> setNotification(notification);
> });
>
> // This listener is fired whenever a user taps on or interacts with a notification (works when app is foregrounded, backgrounded, or killed)
> responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
> console.log(response);
> });
>
> return () => {
> Notifications.removeNotificationSubscription(notificationListener.current);
> Notifications.removeNotificationSubscription(responseListener.current);
> };
> }, []);
in the below i am just showing that details
<View style={{ alignItems: 'center', justifyContent: 'center' }}>
<Text>Title: {notification && notification.request.content.title} </Text>
<Text>Body: {notification && notification.request.content.body}</Text>
<Text>Body: {notification && notification.request.content.subtitle}</Text>
<Text>Data: {notification && JSON.stringify(notification.request.content)}</Text>
</View>
here i want receive the βdataβ field.
i can able to get title, message, i want the data filed,how to get the data filed(data: { someData: βgoes hereβ,page:β1β })
Can some help me how to get the βdataβ field from push notification receive details.because it is having other extra data in json format.