DEV Community

Discussion on: React Native Push Notifications

Collapse
 
ajmal_hasan profile image
Ajmal Hasan • Edited

1) Notifications.events().registerNotificationOpened, Notifications.events().registerNotificationReceivedBackground
and Notifications.getInitialNotification()
is not triggered if u are using with splash screen.

2) For custom icon and color on notification, add icon into all res/mipmap-*
and then use meta-data tag _

Modify the AndroidManifest Like this for resolving above points:

package="com.rnb_boilerplate">

<uses-permission android:name="android.permission.INTERNET" />

<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.google.firebase.messaging.default_notification_icon" 
  android:resource="@mipmap/ic_notifications" />
  <meta-data
  android:name="com.google.firebase.messaging.default_notification_color"
  android:resource="@color/app_bg" />

  <!-- Add this SplashActivity -->
  <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="adjustResize" >
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.INFO" />
      </intent-filter>
    </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
Collapse
 
danielwinkler profile image
Daniel Winkler

In the current version of the lib, the only icon name that worked for me was
@drawable/notification_icon

You can find the reason for that in the code, I opened a PR to update their docs, but for now I'll leave it here to save somebody else some hours of trial and error