当前位置 : 主页 > 网页制作 > React >

react-native-fcm android通知无法正常工作

来源:互联网 收集:自由互联 发布时间:2021-06-15
我是第一次使用 react-native-fcm,根据文档,我已经完成了所有链接工作,并使用firebase控制台中的云消息选项卡发送通知. 发送通知后状态变为完整,IOS工作正常(获取通知)但是android什么都没有
我是第一次使用 react-native-fcm,根据文档,我已经完成了所有链接工作,并使用firebase控制台中的云消息选项卡发送通知.

发送通知后状态变为完整,IOS工作正常(获取通知)但是android什么都没有出现.
我正在使用mi设备进行测试,它具有android N.
这是我的build.gradle设置.

compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "XXXXXX"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 39
        versionName "1.91"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

请帮助我,我正在寻找一个漫长但无法找到的解决方案.
提前谢谢!

Edit after some experiments on 8/6/2018

我已经尝试了很多东西没有什么锻炼,然后我创建了一个新的项目firebase并反应原生.并且一切正在进行(获取通知)然后我开始检查我的旧项目文件和新文件,经过这么多实验我发现问题是工具:node =“replace”我添加了这个因为react-native- facebook-login(google上的一些解决方案我得到了一些错误).

现在请帮我解决这个Android代码如何写它因为我的假设是工具:node =“replace”覆盖我的fcm代码与Facebook登录一个根据this reference.我不能删除工具:node =“替换”其崩溃的应用程序刚点击app图标后.

<application
      tools:node="replace" <-- this is culprit
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
      <receiver android:enabled="true" android:exported="true"  android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
        <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"/>
          <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
      </receiver>
      <!-- <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/icon"/> -->
      <service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
        <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
      </service>
      <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
        <intent-filter>
          <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
      </service>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:screenOrientation="portrait" android:name="com.facebook.react.devsupport.DevSettingsActivity" />

      <!--add FacebookActivity-->
      <activity
        tools:replace="android:theme"
        android:screenOrientation="portrait"
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

      <!--add CustomTabActivity-->
      <activity
        android:screenOrientation="portrait"
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
      </activity>

      <!--reference your fb_app_id-->
      <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/fb_app_id"/>
      <meta-data android:name="com.bugsnag.android.API_KEY"
        android:value="xxxxxxxxxxxxxx"/>
    </application>
即使你应该发布你的android / build.gradle甚至android / app / build.gradle的所有内容,我想帮你说你应该使用react-native-firebase因为react-native-fcm将不再收到新功能.

react-native-firebase has introduced new firebase messaging and remote/local notification features. It has good integration with other firebase features. I would recommend new comers to check that.

Note that there are some advanced features still in progress

handle iOS remote notification when app is not running
custom iOS notification actions
To existing react-native-fcm users
react-native-firebase now can do what react-native-fcm can so it is a waste of effort to build the same thing in parallel.

Since I’m getting busier these days and start feeling challenging to maintain this repo every day while react-native-firebase has a larger team/company backing it, existing users may consider migrating to react-native-firebase.

I’ve created an example project using react-native-firebase as a migration reference

react-native-fcm will still take PRs and bug fixes, but possibly no new feature developement any more.

网友评论