I's just upgraded from v5 to v10 (newest) and react-native from 0.60.4 to 0.63.4, then I am implementing my project, I have this issue.
I _logged_ the message object, so I think the setup is correct
Click To Expand
#### `package.json`:
"@react-native-firebase/analytics": "^10.1.1",
"@react-native-firebase/app": "^10.1.0",
"@react-native-firebase/database": "^10.1.1",
"@react-native-firebase/messaging": "^10.1.1",
"@react-native-firebase/storage": "^10.1.1",
"react": "16.13.1",
"react-native": "0.63.4",
#### `firebase.json` for react-native-firebase v6:
# N/A
### Android
#### Have you converted to AndroidX? - [X] my application is an AndroidX application? - [X] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: 'config.gradle'
buildscript {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// maven {
// // Firebase : Google Play services from 11.2.0 +
// url 'https://maven.google.com'
// }
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.24.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-gcm:16.1.0"
}
}
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// maven {
// // Firebase : Google Play services from 11.2.0 +
// url 'https://maven.google.com'
// }
maven { url "https://jitpack.io" }
google()
jcenter()
}
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
}
}
}
}
subprojects { project ->
if (project.name.contains('react-native-image-picker')) {
buildscript {
repositories {
jcenter()
maven { url "https://dl.bintray.com/android/android-tools/" }
}
}
}
}
subprojects { project ->
if (project.name.contains('react-native-vector-icons')) {
buildscript {
repositories {
jcenter()
maven { url "https://dl.bintray.com/android/android-tools/" }
}
}
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "28.0.2"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.1"
}
if (details.requested.group == 'androidx.appcompat'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.0"
}
if (details.requested.group == 'androidx.vectordrawable'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.0"
}
}
}
}
#### `android/app/build.gradle`:
apply plugin: "com.android.application"
apply plugin: 'newrelic'
import com.android.build.OutputFile
project.ext.react = [
nodeExecutableAndArgs: ["/usr/local/bin/node"],
enableHermes : true,
hermesCommand : "../../node_modules/hermes-engine/osx-bin/hermes",
]
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration.getAt("compileSdkVersion")
buildToolsVersion globalConfiguration.getAt("buildToolsVersion")
defaultConfig {
applicationId PACKAGE_NAME
versionCode VERSION_CODE
versionName VERSION_NAME
minSdkVersion 21
targetSdkVersion 29
ndk {
//abiFilters "armeabi-v7a", "x86" //cho F5s Oppo
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
multiDexEnabled true
}
signingConfigs {
release {
}
debug {
return void
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
// include "armeabi-v7a", "x86"
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
debuggable false
shrinkResources enableProguardInReleaseBuilds
zipAlignEnabled enableProguardInReleaseBuilds
useProguard enableProguardInReleaseBuilds
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.debug
resValue "string", "CodePushDeploymentKey", '""'
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
// def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "version"
productFlavors {
}
defaultConfig {}
packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/armeabi-v7a/libjsc.so'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.facebook.react:react-native:+'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'com.android.support:multidex:1.0.3'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
// def hermesPath = "../../node_modules/hermesvm/android/";
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
// From node_modules
// Paste these line
implementation project(':react-native-interactable')
implementation(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.newrelic.agent.android:android-agent:5.24.1'
implementation('androidx.core:core:1.0.0') {
force true
}
implementation('androidx.legacy:legacy-support-core-utils:1.0.0-rc02') {
force = true
}
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.annotation:annotation:1.0.2'
implementation "androidx.drawerlayout:drawerlayout:1.0.0"
implementation "androidx.coordinatorlayout:coordinatorlayout:1.0.0"
implementation "androidx.vectordrawable:vectordrawable-animated:1.0.0"
// implementation project(path: ":@react-native-firebase_app")
implementation project(':react-native-code-push')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
#### `android/settings.gradle`:
rootProject.name = ''
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-interactable'
project(':react-native-interactable').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-interactable/lib/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':@mauron85_react-native-background-geolocation'
project(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')
include ':@mauron85_react-native-background-geolocation-common'
project(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')
include ':app'
#### `MainApplication.java`:
package com.abivin.vappx;
import android.app.Application;
import android.content.Context;
import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.facebook.react.ReactApplication;
import com.microsoft.codepush.react.CodePush;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.horcrux.svg.SvgPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.github.yamill.orientation.OrientationPackage;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import io.xogus.reactnative.versioncheck.RNVersionCheckPackage;
import br.com.dopaminamob.gpsstate.GPSStatePackage;
import com.airbnb.android.react.lottie.LottiePackage;
import com.rssignaturecapture.RSSignatureCapturePackage;
import com.freshchat.consumer.sdk.react.RNFreshchatSdkPackage;
import com.tron.ReactNativeWheelPickerPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.ninty.system.setting.SystemSettingPackage;
import com.imagepicker.ImagePickerPackage;
import com.showlocationservicesdialogbox.LocationServicesDialogBoxPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.AlexanderZaytsev.RNI18n.RNI18nPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;
import io.invertase.firebase.analytics.ReactNativeFirebaseAnalyticsPackage;
import io.invertase.firebase.messaging.ReactNativeFirebaseMessagingPackage;
// import io.invertase.firebase.analytics.ReactNativeFirebaseDatabasePackage;
// import io.invertase.firebase.analytics.ReactNativeFirebaseStoragePackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
// 2. Override the getJSBundleFile method in order to let
// the CodePush runtime determine where to get the JS
// bundle location from on each app start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AsyncStoragePackage(),
new ReactNativeFingerprintScannerPackage(),
new SvgPackage(),
new SplashScreenReactPackage(),
new NetInfoPackage(),
new OrientationPackage(),
new RNVersionCheckPackage(),
new RNImeiPackage(),
new LottiePackage(),
new GPSStatePackage(),
new RSSignatureCapturePackage(),
new RNFreshchatSdkPackage(),
new RNFusedLocationPackage(),
new ReactNativeWheelPickerPackage(),
new SystemSettingPackage(),
new RNFetchBlobPackage(),
// new RNGestureHandlerPackage(),
new RNDeviceInfo(),
new ImagePickerPackage(),
new MapsPackage(),
new LocationServicesDialogBoxPackage(),
new RNI18nPackage(),
new VectorIconsPackage(),
new RNFloatWidgetPackage(),
new RNTrackLocationPackage(),
new ReactNativeFirebaseAppPackage(),
new ReactNativeFirebaseAnalyticsPackage(),
new ReactNativeFirebaseMessagingPackage(),
// new ReactNativeFirebaseDatabasePackage(),
// new ReactNativeFirebaseStoragePackage(),
new CodePush(getResources().getString(R.string.CodePushDeploymentKey), getApplicationContext(), BuildConfig.DEBUG)
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com"
>
<!-- android:versionCode="1"
android:versionName="1.0" -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!--<uses-sdk android:targetSdkVersion="22" />-->
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="${APP_NAME}"
android:theme="@style/AppTheme"
tools:replace="label"
android:requestLegacyExternalStorage="true"
android:manageSpaceActivity=".MainActivity"
android:usesCleartextTraffic="true">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="" />
<!-- <service android:name=".trackLocationService.TrackLocationService" />-->
<service android:name=".trackLocationService.TrackLocationGoogleApiService" />
<!-- <service android:name="" />-->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_image_picker_paths"
tools:replace="android:resource" />
</provider>
<service
android:name=".floatWidget.FloatingWidgetShowService"
android:enabled="true"
android:exported="false" />
<!-- <meta-data
android:name="io.fabric.ApiKey"
android:value=""
/> -->
</application>
</manifest>
Click To Expand
**`react-native info` output:**
System:
OS: macOS 10.15.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 97.26 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.18.4 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.6 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.0 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
Android SDK:
API Levels: 29
Build Tools: 28.0.3, 29.0.2
System Images: android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_272 - /usr/bin/javac
Python: 3.7.1 - /Users/mac/.pyenv/shims/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.4 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [X] Android
- [ ] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- ^10.1.0"
- **`Firebase` module(s) you're using that has the issue:**
- cloud messaging
- **Are you using `TypeScript`?**
- Yes, "typescript": "^4.0.3"
React Native Firebase and Invertase on Twitter for updates on the library.
the message object
Hello!
You skipped almost all the template, that makes it hard to help you.
Text is vastly preferred to images.
If there is a crash, a crash trace is the most useful way to debug it, please post a crash trace
v10.3.1 is actually newest, and it comes with firebase-ios-sdk 7.3.0 which may have fixed the issue
@mikehardy Sorry for my hurry, my app crash when I call _await messaging().getToken()_, and the object import messaging from "@react-native-firebase/messaging"; before call the function getToken() is the image above.
I feel as though you ignored basically everything I wrote?
@mikehardy :D, I've just updated the template, please take a look, thank you
I've just know the problem that I don't add this to android/build.gradle
``
project.ext {
set('react-native', [
versions: [
// Overriding Build/Android SDK Versions
android : [
minSdk : 16,
targetSdk : 30,
compileSdk: 30,
buildTools: "30.0.2"
],
// Overriding Library SDK Versions
firebase: [
// Override Firebase SDK Version
bom : "26.0.0"
],
],
])
}
``
@danghv I don't believe you want that. If you have version v10.3.1 of react-native-firebase, the @react-native-firebase/app module will pull in firebase-android-sdk 26.2.0 which is current. And as we update versions here we will pull in fresh ones. If you do the override yourself you will have to remember to update the firebase-android-sdk yourself, is that something you check frequently and will keep up to date?