【发布时间】:2018-06-06 12:31:10
【问题描述】:
我第一次使用react-native-fcm,根据文档,我已经完成了所有链接工作,并在firebase控制台中使用云消息选项卡发送通知。
在发送通知状态完成后,对于 IOS 来说它工作正常(收到通知),但 android 什么都没有出现。 我正在使用具有 android N 的 mi 设备进行测试 这是我的 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"
}
}
请帮助我,我正在搜索很长但无法找到解决方案。 提前谢谢!!!
在 2018 年 8 月 6 日进行一些实验后进行修改
我已经尝试了很多没有锻炼的东西,然后我创建了一个新项目 firebase 并做出了原生反应。一切都在进行中(收到通知)然后我开始检查我的旧项目文件和新文件,经过多次实验后我发现问题出在tools:node="replace" 我添加了这个是因为react-native-facebook-login(谷歌上的一些解决方案我遇到了一些错误)。
现在请帮助我编写这个 android 代码,因为我的假设是 tools:node="replace" 根据 this reference 用 Facebook 登录代码覆盖了我的 fcm 代码。我无法在单击应用程序图标后删除 tools:node="replace" 其崩溃的应用程序。
<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>
【问题讨论】:
-
您是否也尝试过编辑 AndroidManifest.xml?
-
@M.Khajavi 是的,我根据文档做了。除了这个,我们还需要添加什么吗?
标签: android firebase react-native google-cloud-messaging react-native-fcm