Confusion integrating react-native-firebase with Expo - firebase

I'm new to React Native development, and I'm making a development environment for a cross-platform app I'm building with Expo and Firebase.
I'm trying to integrate react-native-firebase with Expo because it's the only way I can use Firebase's 'App Check' functionality. I want a managed workflow where I'm not having to touch native code and am using the EAS development build.
I've tried to set up my environment using the following article, but it's left me confused about something - how do I connect my app to firebase? Do I use the standard web JS SDK, or is there something else I should be using?
I've looked at the react-native-firebase docs concerning the expo, which hasn't helped.
What's also confusing is this: when I was trying to add firebase to my android app on the firebase console, it mentioned adding the firebase SDK to a build.gradle file - something which my project doesn't have. So have a missed a step in my setup?
If it's any help, here are the steps I've taken for my project so far:
1.) Created app with npx create-expo-app
2.) npm install -g eas-cli
3.) npx expo install expo-dev-client
eas build
4.) npx install #react-native-firebase/app
5.) Set up a project on firebase. Download google-services.json and GoogleService-Info.plist, and add them to the root of my expo project
6.) Configure app.json as follows:
"ios": {
"googleServicesFile": "./GoogleService-Info.plist",
"supportsTablet": true,
"bundleIdentifier": "com.******.testapp"
},
"android": {
"googleServicesFile": "./google-services.json",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.******.testapp"
},
"web": {
"favicon": "./assets/favicon.png"
},
"plugins": [ "#react-native-firebase/app"],

Gradle is a build tool commonly used for mobile application projects. However as you are using Expo, Expo is your build tool rather than Gradle.
In your app.json file, you can see that the configuration there mentions ./GoogleService-Info.plist and ./google-services.json. These are the configuration files produced by the Firebase Console once you register your iOS and Android applications.
They can be redownloaded following these directions.
Go to your Project settings in the Firebase console.
In the Your apps card, select the bundle ID/package name of the app for which you need a config file.
Click the download link for GoogleService-Info.plist or google-services.json (as appropriate).
Save the file to the root of your project, making sure that you only have the most recent downloaded config file.

Related

Error while implementing firebase in expo snack (react native)

image
I encounterd this error while importing firebase to my expo snack which is use for authentication in my app project. Can anyone help me?
The problem is with babel:
Try this first: npm add #babel/runtime
And if that doesn't work try to do this:
as was mentioned above, looks like the presence of this property
watchFolders: [${__dirname}/../..],
in metro.config.js solves the problem. I have a monorepo and mobile app is one of packages, that is why I need ../..
BTW in my case, interopRequireDefault problem appears only when I make a release build with
react-native run-android --variant release
developing mode ( react-native run-android ) works fine even without metro.config.js file
Also, there is no problem if a project is not configured as Monorepo
Reference: https://github.com/facebook/react-native/issues/27712

Firebase Crashlytics IOS SourcePackages not found

I tried setting up Firebase Crashlytics to my React Native project.
I received the following error when I was building the project after I added the build phase script.
Script I added from the firebase guide (can be found here) :
Error:
MY-APP-ABC/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run:
No such file or directory
When I look in the folder of MY-APP-ABC, I don't see the SourcePackages folder anywhere.
If you installed firebase using cocoa pods use:
"${PODS_ROOT}/FirebaseCrashlytics/run"
If you installed firebase using Swift Package Manager use:
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"

Firebase Crashlytics NDK unstripped files

I have an SDK that uses C++ code. The SDK exports 4 different modules in a maven repo that I publish on either a local maven repo or on GitHub packages.
The apps that consume the SDK should be able to use Firebase Crashlytics and get reports of crashes in the native code as well.
The first problem I have is that I need to provide to the Firebase plugin the folders unstrippedNativeLibsDir and strippedNativeLibsDir:
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir "???"
strippedNativeLibsDir "???"
}
If I go to the project where I build the SDK I can see: build/intermediates/merged_native_libs/release and build/intermediates/stripped_native_libs.
Are these the unstripped and stripped folder respectively?
Is there any documentation about what exactly those folders are supposed to contain?
Anyway if I configure the app firebaseCrashlytics to point to these folders I still need to fix another issue.
I get:
Crashlytics could not find NDK build tasks on which to depend. You many need to manually enforce task dependencies
It looks like since I'm building the libs that use the NDK in another project, then the Firebase plugin does not work.
What am I supposed to do?
Is it possible to get the Crashlytics NDK working even if I build the libraries independently with a separate project?
The only way I made it work was to build the libraries along with the app. The libraries were in separate repos anyway but I included them as sub-repositories in the app.
In this way, you solve the issue of not finding NDK build tasks on which to depend.
I know this is not the answer though

How to integrate firebase in an Ionic project (android/iOS)?

I am reading articles and testing ways to implement analytics and push notifications in my Ionic app using firebase.
My ionic app targets both android and ios platforms, so where do I place the google-services.json firebase file? Do I have to create an 2 apps within firebase if I need to use firebase for android and iOS?
I am reading many articles some of which say root folder, whereas some mention to put it in the apps folder. Some say we have to then update the config.xml to include the foll:
<resource-file src="google-services.json" target="app\google-services.json" />
I have also read that we need to update the gradle file with application and project level dependencies.
I have put the file in platform/android/app folder and things are working correctly now.
I just want to know what is the best practice when using Ionic and Firebase, where do I place the file and what config changes do I have to make?:
For an Ionic android app
For Ionic iOS app
For Ionic app for both android and iOS platforms
Have a look at the documentation of the firebase plugin :
https://github.com/arnesson/cordova-plugin-firebase
For Android, you have the google-services.json file, and for iOS you have the GoogleService-Info.plist file. These files are required by firebase to work on both iOS and Android. You have to place theses files at the same level as config.xml.
This plugin uses a hook (after prepare) that copies the configuration
files to the right place, namely platforms/ios/\/Resources for ios and platforms/android for android.
So you don't need the resource-file directive in your config.xml, since it is copied automatically.
You don't need to edit the build.gradle file, but If you have other google play plugins installed (like maps or admob), the compilation may not work.
Your build may fail if you are installing multiple plugins that use
Google Play Services. This is caused by the plugins installing
different versions of the Google Play Services library. This can be
resolved by installing cordova-android-play-services-gradle-release.
If your build is still failing, you can try installing
cordova-android-firebase-gradle-release. For more info, read the
following comment about locking down the specific versions for play
services and firebase. It is suggested to use + instead of 15.+ to
ensure the correct versions are used.
EDIT : Since you're using cordova-plugin-firebase-analytics and not cordova-plugin-firebase, it seems that they didn't implement any hook to copy the files. You'll have to place these directives in your config.xml :
<platform name="android">
<resource-file src="google-services.json" target="app\google-services.json" />
...
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
...
Be sure to install cordova-support-google-services

Generate apk file for meteor app

I have a project is working for android browser. Is there a way to generate the apk file?
Also, are there anything that I shoud know before generating the apk file?
There are a few steps to follow in order to generate the Android application file (.apk) from a meteor app:
meteor install-sdk android
Have the mobile-config.js file in your project root (mobile-config.js example)
meteor add-platform android
meteor build ~/your-output-dir --server=yourapp.meteor.com
Then you will have your .apk file in ~/your-output-dir/android/unaligned.apk
If you want to proceed and submit to Google Play Store, here are the steps to follow: https://guide.meteor.com/mobile.html#submitting-android
Hope this helps!
You can build an APK file with meteor build command.
Read more about it in the docs: http://docs.meteor.com/#/full/meteorbuild or by typing meteor help build in your terminal.
Starting with Meteor 1.2, the bundled Android tools have been removed and a system-wide install of the Android SDK is now required. This should make it easier to keep the development toolchain up to date and helps avoid some difficult to diagnose failures. The meteor install-sdk command no longer attempts to download and install the Android tools for you (it has been deprecated and just points you to these instructions).
like imslavko says, meteor build works pretty fine, also if you are looking for more information take a look on this Meteorpedia
It work for me
Reegards
As of now playstore has started giving warning while uploading APK about unoptimised bundle and insisting for uploading Android app bundle.
Insted of generating APK why not generate .aab of your project and reduce size of the application.
For people wondering about how to generate .aab for your existing project can read my blog here:
My blog link

Resources