How to receive notifications from Firebase Cloud Messaging in React Native - android

I have a react native project and want to be able to receive notification from FCM. I have set up the project ( generated a google-services.json file for my project, modified the build.gradle files accordingly etc ) but so far I haven't been able to run the project. I am using React Native Firebase library https://rnfirebase.io/ but the experience is just not good so far. I've been stumbling from error to error like the one below:
Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app().
Ensure you have:
1) imported the 'io.invertase.firebase.app.ReactNativeFirebaseAppPackage' module in your 'MainApplication.java' file.
2) Added the 'new ReactNativeFirebaseAppPackage()' line inside of the RN 'getPackages()' method list.
I'm just done trying to get the tooling to work. Can you tell me what other approach I can take to get firebase notifications to work for a React Native project that doesn't make use of the library above ?

Have you followed the suggestions in the error message? Also what could work is deleting the build and cache of your android project, and then rebuilding the application. What version of firebase you are using?

Related

Not able to add dependency to android project in flutter

Hello I am new to flutter and i want to do native function calls using flutter, i wrote an sample native code app and it is working as expected. Now i want to use some packages on my android code, which is platform specific.
I have added my dependcies in my build.gradle file and it the gradle build is success,
But i cannot use the package there,
say for example: i have added the dependency for the com.squareup.okhttp3:okhttp:3.4.2 and gradle build is success and now icannot access their methods and other stuffs. Please let me know to what to do with it. Thanks in advance.enter image description here
Finally it worked, i opened the android project as an new android project in android studio which resolved the issue.

Android Facebook Flutter login crashes app

Hey so I have recently started developing an app using flutter and I have already coma across a few issues. I'll quickly resume my situation :
My app uses firebase auth and I uses the android studio refactor feature for androidX.
This managed to get me a working application with a login form but no way to fill in the login form because the android API 28 has a bug in that it does not show the keyboard after you higlight the textinput. But for fire auth you need the API level 28 ...
I managed to get around this by using the flutter channel dev.
Now so far everything works login in and registering users with the firebase auth.
Next I want to implement the facebook login and this is where I encountered even more trouble.
I used the https://github.com/roughike/flutter_facebook_login package and followed all the steps and went through the whole configuration on the firebase page and the facebook developer page.
Add the res/strings.xml
Add permission the manifest
Add and the two under the application key in the android manifest
Add "implementation 'com.facebook.android:facebook-login:4.40.0'" under the app level gradle dependencies
Checked the jcenter() in the project level grable repositories
The actual dart code seems fine and the project builds and runs correctly on IOS
I do not get any errors even running flutter in verbose mode. The logcat is also completly empty.
I am at a complete loss it's really starting to feel like flutter is not really stable after all.
Any help would be greatly appreciated.
Thanks
EDIT: This issue seems to be androidX related and should be fixed as soon as this pull request :
https://github.com/roughike/flutter_facebook_login/pull/87/commits/70dec4403710eb4c52a98e035a0a5e7d7f551d76
is merged.
Ok I got it working by copying the repository locally and adding the changes in the aforementioned pull request.
Then in my pubspec file I used the path: key to set the dependency to my local file instead of the official git.
you can also use
git:
url: (url to your fork with the fixes in place)
I had to run flutter clean before rebuilding the app and now everything works.
EDIT A comment has just been added on the pull request thread :
As we are not sure when this will be merged, you can adjust your pubspec.yaml in the meantime:
dependency_overrides:
flutter_facebook_login:
git:
url: https://github.com/yudaprama/flutter_facebook_login
ref: android-x

CrashlyticsMissingDependencyException when integration with MarmaladeSDK and Firebase

I tried to use Crashlytics instead of FirebaseCrash Reporting. I added all relevant Libraries: crashlytics, fabric, answer, beta and everything compiled and started properly on my Android device. I'm working with MarmaladeSDK which has no AndroidStudio/gradle integration. I need to add every lib by myself to the build system (jars, Android Manifest, Resources mainly).
I have two issues:
Crashlytics is not started automatically. I had to call
Fabric.with(this, new Crashlytics()); Which aar library is reponsible for starting the crashlytics services?
I got an CrashlyticsMissingDependencyException with the error message:
This app relies on Crashlytics. Please sign up for access at
https://fabric.io/sign_up, install an Android build tool and ask a team
member to invite you to this app's organization.
How does chrashlytics gets the knowledge that Firebase is the new destination and that there is no need to register at the fabric.io website?
I have no idea what apply plugin:'io.fabric' does? Can I mimic this behaviour even without Android studio? My main issue is probably that gradle does some magic which I don't understand and I assume that apply plugin:'io.fabric' could be responsible for that.

Unity android plugin for FCM

I'm trying to add Google FCM push notification function to Unity project. I'm surprised that there are no resources about Google FCM for Unity. There are only old Google GCM resources. This is my step-by-step progress below.
Make Android Studio project and register it to a FCM console project
Add google-service.json to '/app' and configure build.gradle (project and module)
Add MyFirebaseInstanceIDService, MyFirebaseMessagingService java classes and onTokenRefresh, sendRegistrationToServer, onMessageReceived, sendNotification methods according to sample example in FCM document
Add services for the classes to AndroidManifest.xml
After that, I tested the Android Studio project on mobile, and FCM console push notification works well. Then, I started to configure the Android Studio project for Unity.
Change 'application' to 'library' in build.gradle (module) and add deleteOldJar, exportJar for AndroidPlugin.jar
Add classes.jar of Unity to Android Studio library and module setting
Remove 'android:icon ...', 'android:theme ...' in AndroidManifest.xml
Export jar and add AndroidPlugin.jar, AndroidManifest.xml to 'Plugins/Android' in Unity
Then, I tested the Unity project on mobile. It is built without exception, but FCM console push notification didn't work. (I made test log for confirming that the Android Studio libray is well plugined for Unity, the log worked well)
Maybe, there are somethings to add to 'Plugins/Android' except AndroidManifest.xml and AndroidPlugin.jar like references below.
Google firebase analytics plugin for unity - StackOverflow
http://joxi.ru/Q2KeQD7C3zdYrj
But, I couldn't find my answer. Please let me know what I have to do or add.
Sorry for bad english and long explanation. Many thanks :)
I used Unity SDK in OneSignal.
It is very simple, easy, and cool SDK for push notification.
Reference link below.
https://onesignal.com/
This approach will not be feasible.
Jar files do not contain resources, and as such, the json file will be missing from the jar build. Alternatively, aar files, which would in theory contain the resources, are interpreted by Unity3D as pure plugin and ignores the resources or at least some, specially when using gradle. But Unity is getting better at it.
Try https://firebase.google.com/docs/unity/setup. It's new and I got the sample project to work already.
Just to add: the new Plugin of Firebase for Unity3D worked liked a charm. Use cases like pure system try notification don't need a single line of additional programming on the client side. Data Messages are very easily implemented as well.

How to initialise Crashlytics?

I have integrated the Crashlytics library using these steps(as I have done before without any issue)
Download plugin from https://fabric.io/onboard/pending
Install the plugin on Android Studio
Follow instructions, ie allow the plugin to make changes to build.config, manifest and main activity.
Build project and run app.
But I can not get it to initialise properly.
Either I get the error Failed to create app with Crashlytics service.
Or if I extend Application and initialise it in onCreate() using Fabric.with(this, new Crashlytics()) I get Initializing Crashlytics 2.2.2.37 but nothing happens. The plugin and web portal both don't show any progress.
I have tried reinstalling Crashlytics, reinstalling the plugin and cleaning the Project.
My project consists of multiple gradle libraries and a(apart from main) module library; in case that is relevant.
Once you have setup your crashlytics with Fabric.with(this, new Crashlytics()) you can force a crash to test the things with: Crashlytics.getInstance().crash();
Once you have crashed you will start to see the data on the web dashboard.
You can also log custom data by using Crashlytics.getInstance().core.log()
Fixed, Crashlytics wasn't getting internet access because of an adblocker.

Categories

Resources