Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29437

getInitialNotification method not getting called when app is in background in react native

$
0
0

In android, I am trying to call getInitialNotification() method in my componentDidMount of App.js Class but when my app is in background and i click on notification my app is not opening by clicking on notification and also notification is getting remove

here is my componentDidMount method code

  firebase.notifications().getInitialNotification()            .then((notificationOpen: NotificationOpen) => {                if (notificationOpen) {                    console.log('getInitialNotification AppJS : ########: ')                    // App was opened by a notification                    // Get the action triggered by the notification being opened                    const {action, notification} = notificationOpen                    let item = JSON.parse(notification.data.body)                    console.log('getInitialNotification AppJS : ########: item ', item)                    console.log('getInitialNotification AppJS : ########: action ', action)                    setTimeout(() => {                        EventBus.getInstance().fireEvent('NOTIFICATION', {item: item})                    }, 5000)                }            })

here is my AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.CAMERA"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><application      android:name=".MainApplication"      android:label="@string/app_name"      android:icon="@mipmap/ic_launcher"      android:roundIcon="@mipmap/ic_launcher_round"      android:allowBackup="false"      android:usesCleartextTraffic="true"      android:theme="@style/AppTheme"><activity          android:name=".SplashActivity"          android:label="@string/app_name"          android:launchMode="singleTask"><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:screenOrientation="portrait"          android:exported="true"          android:windowSoftInputMode="adjustResize"          android:launchMode="singleTask"      /><activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /><meta-data        android:name="com.google.android.geo.API_KEY"        android:value="APIKEYVALUE"/><service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"><intent-filter><action android:name="com.google.firebase.MESSAGING_EVENT" /></intent-filter></service><service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService"><intent-filter><action android:name="com.google.firebase.INSTANCE_ID_EVENT"/></intent-filter></service><service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" /></application></manifest>

here is my SplashActivity.java code

@Override        protected void onCreate(Bundle savedInstanceState) {            super.onCreate(savedInstanceState);            Intent fcmIntent = this.getIntent();            Bundle bundle = fcmIntent.getExtras();            Intent intent = new Intent(this, MainActivity.class);            intent.putExtras(fcmIntent);            startActivity(intent);            finish();        }

Viewing all articles
Browse latest Browse all 29437

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>