push notifications do not load data when the standalone application is closed in android


First of all, thank you for reading what I have to say.
I apologize if this has already been solved in another publication but I tried hard to try on the forums, all the publications I found do not have the same symptoms and the documentation did not help me to solve this question.

When you click on a notification received from FCM with the application closed, the application starts but does not display the notification that must be loaded on a screen if the condition “if (this.notification! == null) {…” is true, in addition the physical button to show the applications that are in the background, simply stops responding, clicking the home button, after an average period of 10 seconds the application opens again until I click home and then click the button to display it in the background and close it completely closing the plication, it opens infinitely alone, regardless of whether or not to use the device at the moment, becoming uncomfortable and this is horrible for the user.

Expected behavior:
When you click a notification with the application closed, the application must start and view the notification on a specific screen.

Additional information:

  • In my client expo using virtual device or a real android device, it seems to work very well even if I close the client expo application.
  • With the application activated or in the background, the behavior is expected both using the client expo and an apk generated with build: android.
  • My application does a POST check to an external server in “async registerForPushNotificationsAsync ()” after grabbing the token and send it to the server to check and retrieve user data and create a session on the server using the token as authentication information, after that gets a json that if not empty directs to the home screen and if it is empty or null directs to the login screen.
  • My “Notifications.addListener ()” is in the home under “componentDidMount ()” where a new POST request is made to the server to get a list of links.
  • Only when I receive a notification that “Notifications.addListener ()” calls “_handleNotification” and the condition becomes true and the Push call screen displaying the notification.
  • No error or warning during client expo testing.

Code responsible for calling the Push screen:

componentDidMount() {
        this._notifictionSubscription = Notifications.addListener(this._handleNotification);
        this.setState( { isMounted: true }, () => {
             console.log("token: ", this.props.navigation.state.params.token);
            this.setState({ token: this.props.navigation.state.params.token, userName: this.props.navigation.state.params.name, ref: this.props.navigation.state.params.ref, photo_url: {uri: this.props.navigation.state.params.photo_url}, url: this.props.navigation.state.params.url });

            return fetch('https://mydomain.api?token=' + encodeURIComponent(this.props.navigation.state.params.token))
            .then((responseJson) => responseJson.json())
            .then((response) => {
                console.log("Get User Urls Api_Result: "+JSON.stringify(response));
                if (response.success) {
                    this.setState({ urls: response.data });
                    if (response.data.length > 0){
                        this.setState({uri: this.state.url});
                } else {
            .catch((error) =>{

_handleNotification = (notification) => {
        this.setState({notification: notification});

        if (this.notification !== null) {
            this.props.navigation.navigate('Push', {title: this.state.notification.data.title, body: 
           this.state.notification.data.body, image: this.state.notification.data.image, id: this.state.notification.notificationId});
        } else {
            console.log("Notification null");

closed #2

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