Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Android app is reloaded when push notification opened and onNotification is not triggered #1623

Closed
MahmudHasanMenon opened this issue Aug 30, 2020 · 8 comments

Comments

@MahmudHasanMenon
Copy link

My react-native android app is automatic reload when open local push-notification and sometimes onNotification is not get triggered.

  1. when local notification show and i press the notification it reloads the whole app and onNotification is not called
  2. sometimes onNotification get called when componentDidmount called without opening any local-push-notification

react-native : 0.61.2
react-native-push-notification: 5.0.1

Note: In react-native 0.63 version i didn't find this issue. in react-native 0.63 version local-push notification working fine.

here is my AndroidManifest.xml
`

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">

  <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
            android:value="YOUR NOTIFICATION CHANNEL NAME"/>
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>


                  <!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                android:value="false"/>
    <!-- Change the value to false if you don't want the creation of the default channel -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.channel_create_default"
                android:value="true"/>
    <!-- Change the resource name to your App's accent color - or any other color you want -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

    <service
        android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

   <activity
        android:name=".SplashActivity"
        android:theme="@style/SplashTheme"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />  
        </intent-filter>
    </activity>

  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
    android:exported="true">
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
`
@Dallas62
Copy link
Collaborator

Hi @MahmudHasanMenon
I suggest you to search in the issues history, this has been discussed recently and it's probably due to the splash screen activity.
Best regards

@MahmudHasanMenon
Copy link
Author

@Dallas62 thanks a lot.....please help me to find out or give that link where it is discussed?

@MahmudHasanMenon
Copy link
Author

MahmudHasanMenon commented Aug 30, 2020

@Dallas62 (#1592 (comment)) i tried this but my issue is not solved. Please help me and suggest some solution.

@MahmudHasanMenon
Copy link
Author

this worked for me..... AndroidManifest.xml
<activity android:name=".MainActivity" android:launchMode="singleTask"

@react5Moon
Copy link

this worked for me..... AndroidManifest.xml
<activity android:name=".MainActivity" android:launchMode="singleTask"

It's not working for me

@abo-rythm
Copy link

this worked for me..... AndroidManifest.xml <activity android:name=".MainActivity" android:launchMode="singleTask"

not working for me either, still trying to figure this out

when in background/ killed, on Press notification triggers onNotification and everything works fine
when in foreground, onNotification is triggered, but the app reloads so its effect is not applied

Any progress?

@Srikanth-OneCode
Copy link

Yes same here. Facing the same issue as @AdrianBordeianu

@abo-rythm
Copy link

Screenshot 2021-12-13 at 16 40 00

For me the issue was that I did not add the userInfo object on localNotification, and because of that it didn t have data to navigate with, causing that sort of refresh. Solved it by putting redirect data on userInfo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants