React原生推送通知中Android资源链接失败

问题描述 投票:0回答:1

enter image description here当我添加到 android Manifest 中时,我收到此错误任何人都可以帮助如何集成反应本机推送通知

有知道的朋友请帮帮我 {代码}

 <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>


{代码}

如何解决这个错误?我需要帮助

android react-native push-notification android-manifest
1个回答
0
投票

我在你的代码中发现了 4 个问题

  1. 除了振动权限之外,我们还需要再授予一项权限(https://github.com/zo0r/react-native-push-notification

2)您的元和接收者标签的位置在代码中不正确。

3)对于高于 12 的 android api,我们需要分别向所有接收器显式添加 android:exported true 或 false。

4)如果与(https://github.com/zo0r/react-native-push-notification)集成,还需要添加服务标签。

附上AndroidManifest.xml,希望有帮助

<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>    
© www.soinside.com 2019 - 2024. All rights reserved.