Skip to content

[ANDROID] Notifications.getInitialNotification() no data when app is in kill state #906

@viktor-CCM

Description

@viktor-CCM

Notifications.getInitialNotification() return undefined when the application is in a kill state.
If the application is foreground and the user tap on the notification - Notifications.events().registerNotificationOpened works properly.

const registerNotificationOpened = async () => {
    Notifications.events().registerNotificationOpened((notification) => {
      console.log('Notification opened by device user', notification.payload);
    });

    const initialNotification = await Notifications.getInitialNotification();
  };

Case 1 (Android)
Dead state (100% dead)
Click on the notification message
App will open
Notifications.getInitialNotification() return undefined

In iOS it works properly.


"react-native-notifications": "^4.3.1",
"react-native": "^0.69.6",


// Android Manifest

<uses-permission android:name="android.permission.INTERNET" />
<permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<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/BootTheme">
    <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/notification_icon" />
    <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
                notification message. See README(https://goo.gl/6BKBk7) for more. -->
    <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/primary" />
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustPan"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
</application>

Google service package

dependencies {
    classpath("com.android.tools.build:gradle:7.1.1")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("de.undercouch:gradle-download-task:5.0.1")
    classpath 'com.google.gms:google-services:4.3.10'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}

// Test devices
OnePlus 9R android 12
Pixel 4 API 30 (simulator)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions