Using data from push notifications to navigate to screen

Please provide the following:

  1. SDK Version: 40.0.1
  2. Platforms(Android/iOS/web/all):all

I want to navigate to a specific nested screen in my app, passing it specific params, that are available in a push notification.

Near the root of my app I have

Notifications.addNotificationResponseReceivedListener(response => {
  const {
    questionSet,
    questionId
  } = response.notification.request.content.data;
  console.log(questionSet, questionId);
});

below that I have

export default function Navigation() {
  return (
    <NavigationContainer linking={LinkingConfiguration}>
      <RootNavigator />
    </NavigationContainer>
  );
}

the linking config file looks like

import * as Linking from 'expo-linking';

export default {
  prefixes: [Linking.makeUrl('/')],
  config: {
    screens: {
      Root: {
        screens: {
          Questions: {
            screens: {
              QuestionScreen: 'question/:id'
            }
          }
        }
      }
    }
  }
};

the QuestionScreen currently knows what to load from the route.params. Another component will load it as follows…

  onPress={() => {
                      navigation.navigate('QuestionScreen', {
                        questionSetId: questionSet.questionSetId,
                        ordered: questionSet.ordered
                      });
                    }}

I’m not clear how to navigate to the QuestionScreen with specific parameters using the push notification data.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.