Search code examples
androidreact-nativepush-notificationandroid-manifest

Android resource linking failed in React native push Notification


enter image description herewhen I add in android Manifest then I get this error can anyone help how to integrate react native push notification

any buddy know please help me {Code}

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <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 tools:replace="android:resource"      android:name="com.google.firebase.messaging.default_notification_color" android:resource="@android:color/white" />
        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
     ...

          <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"  android:value="Firebase Notifications"/>
          <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="Firebase Notifications"/>
          <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"   android:resource="@android:color/white"/>

          <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
          <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
          <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"
              android:exported="true">
              <intent-filter>
                  <action android:name="android.intent.action.BOOT_COMPLETED" />
                  <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                  <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
              </intent-filter>
          </receiver>
          
      </activity>
    </application>
</manifest>


{Code}

How to solve this error? I need need help


Solution

  • i see 4 issues in your code

    1. Along with vibrate permission we need to give one more permission (https://github.com/zo0r/react-native-push-notification)

    2)Your position of meta and receiver tag is not correct in code.

    3)For android api's higher that 12 we need to explicitly add android:exported true or false to all receivers respectively.

    4)If integrating with (https://github.com/zo0r/react-native-push-notification) the service tag needs to be added as well.

    Attaching AndroidManifest.xml , hope it helps

    <uses-permission android:name="android.permission.INTERNET" />
    <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/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="true"/>
     <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions"  android:exported="true" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"  android:exported="true" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"  android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </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>    
        </application>