Error : FacebookSDK has not been initialized yet using react native - firebase

So I am trying to add a facebook sign up connect to firebase to my react-native application and expo keep telling me this error . I dont really know what to do because I thought that Facebook SDK was auto initialized on Application start.
This is my Sign In function.

According to the documentation: https://docs.expo.io/versions/latest/sdk/facebook/, you need to initialize the SDK with this function:
Facebook.initializeAsync(appId: string | undefined, appName: string | undefined): Promise<void>
Calling this method ensures that the SDK is initialized. You have to call this method before calling logInWithReadPermissionsAsync to ensure that Facebook support is initialized properly.
You should call this method in your App.js or any top level component.

Came here from Github, after upgrading from Expo SDK 35 => 36 ran into this issue.
Adding this line to app.json fixed it:
"facebookAutoInitEnabled": true
From docs: https://docs.expo.io/versions/latest/sdk/facebook/
The above answer may work as well, but this fixed it in my case

Related

Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2

I have a NodeJS Firebase Function that uses firebase-admin sdk. It has been working alright since last year. In the last 2 weeks, the following error started showing in the log:
Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: 404 page not found
Could it be an issue with the version of "firebase-admin": "^7.3.0" I am using?
Have anyone faced the same issue and can you offer some direction on what might have been the cause?
This looks like a problem with NodeJS, the version 8 is no longer supported as per the documentation. Deployment of functions to the Node.js 8 runtime was disabled in the Firebase CLI on December 15, 2020 and that is most likely why you are facing the 404 error.
To migrate to a newer supported version of the NodeJS runtime, use the documentation.
Also, I do not suspect any issue with your firebase-admin version 7.3.0.
I have the same error, but I was already on Node 12. Also, the function was running well for years and now is crashing due to this :/
The only solution that worked for me was to change auth to admin from default to explicit passing of service-account.json like is described here in docs https://firebase.google.com/docs/reference/admin/node/admin.credential#cert
For those who are deploying to Google Cloud Functions, requirements:
Node >= 10
Initialisation:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

Value of "WL.Client.Push" is coming as undefined

I am getting the value for WL.Client.Push as undefined when launching the application. Hence, the below is coming as false.
if(WL.Client.Push)
And that's the reason my push is not getting registered.
Please advise how can I define WL.Client.Push.
This normally happens when you try to use WL.Client.* APIs before the SDK initialization has been completed.
The right point to start using the WL.Client APIs is after the flow has entered the wlCommonInit() method.
Do note that IBM MobileFoundation 7.x is out of support, and you should move to MobileFoundation 8.0.
You can use MFPPush object to invoke Push APIs.
Documentation here.
A working sample can be found here.

Why do I get "Client is not yet ready to issue requests" - Firestore get() fails when called by Schedule function

In my Firebase project I have a functions.pubsub.schedule().onRun() that runs every 5 minutes to perform some calendar related tasks. It needs to look up in my Firestore collections and does so with a .get() query.
This has been working fine until sometime 2020-03-13 in the morning where the function started to throw
2020-03-13 09:36:02.326 CET scheduledHooks 1042277797598294
Error: INTERNAL ERROR: Client is not yet ready to issue requests.
at Firestore.get projectId [as projectId] (/srv/functions/node_modules/#google-cloud/firestore/build/src/index.js:401:19)
at Query.toProto (/srv/functions/node_modules/#google-cloud/firestore/build/src/reference.js:1556:42) at Query._get (/srv/functions/node_modules/#google-cloud/firestore/build/src/reference.js:1466:30)
at Query.get (/srv/functions/node_modules/#google-cloud/firestore/build/src/reference.js:1457:21)
at FirebaseActivitiesCollection.<anonymous> (/srv/functions/lib/collections/activities/FirebaseActivitiesCollection.js:32:40)
at Generator.next (<anonymous>) at /srv/functions/lib/collections/activities/FirebaseActivitiesCollection.js:8:71
at new Promise (<anonymous>) at __awaiter (/srv/functions/lib/collections/activities/FirebaseActivitiesCollection.js:4:12)
at FirebaseActivitiesCollection.getActivitiesByInterval (/srv/functions/lib/collections/activities/FirebaseActivitiesCollection.js:27:16)
I can't track that I have changed anything, could it be that Firebase made some changes that I should be aware of or am I missing an obvious clue in this error message?
My other Cloud Functions and the Firebase JavaScript SDK still work fine.
Extra info: The same code works on my other environment where I have not deployed. This of course led me to search for changes in the deployed code, but I can't find any!?
It seems by the error, that the project was not connected and initialized correctly. As per the official API here, this error occurs when:
Returns the Project ID for this Firestore instance. Validates that
initializeIfNeeded() was called before.
I would recommend you to check that. In case you are still facing, I would say for you to contact the Firebase Free Support. Since you mentioned that it was working until yesterday morning, it might be some change on their side.
Hope this helps!
This turned out to be a very simple matter of initialization of Firebase:
Before I had:
// Initialize firebase
admin.initializeApp(functions.config().firebase)
..And it worked fine until it didn't anymore.
Now I have:
// Initialize firebase
admin.initializeApp()
... And it works again
Got the same error while running some jest tests involving firebase. Problem was that I didn't have GOOGLE_APPLICATION_CREDENTIALS environment variable set.
Since I was running them locally on my machine, exporting this variable in terminal before running the tests was sufficient for my case:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials/file.json

FieldValue.increment for Cloud Firestore in Flutter

I'm creating a android app using flutter and Firebase Firestore.
I would like to add that new FieldValue.increment functionality which is apperently available in Firebase since this april but i've got an error:
The method 'increment' isn't defined for the class 'FieldValue'.
Here is my code that i've tried:
onTap: (){
Firestore.instance.document('docRef').updateData({"numberOfDocs": FieldValue.increment(1)});
}
I'm just a beginner programmer but when i checked that field_value.dart file it's missing "increment" implementation.
So, is it right answer to say that flutter team didn't yet implemented that functionality?
I've seen a tutorial where increment is already used in some .js code but for me it's not working.
https://www.youtube.com/watch?v=8Ejn1FLRRaw
This has been added to the cloud_firestore Flutter plugin as of version 0.10.0.
You can use FieldValue.increment with a double (e.g. FieldValue.increment(1.0)) or an int (e.g. FieldValue.increment(2)).
Here is the relevant pull request.
If anyone reads this before the version is pushed to Pub: The link to the version will not yet work, but in the meantime you can use this Git commit, which contains a fix I did.
User that Import:
import 'package:cloud_firestore/cloud_firestore.dart';
For Increment:
await FirebaseFirestore.instance.collection('post').doc(postId).update({"like": FieldValue.increment(1)});
For Decrement:
await FirebaseFirestore.instance.collection('post').doc(postId).update({"like": FieldValue.increment(-1)});
As far as I can see in the change log for FlutterFire, the increment operator has not been added yet.
I added a feature request to the repo.

WinPhone 8.1 register Push Id to Azure notification hub error: The type name 'MobileService' does not exist in the type 'App'

I would like to configure Push notifications for a Xamarin Forms Windows 8.1 Silverlight project. Originally I was using MPNS but am attempting to switch over to WNS. Switching over I am now running into an error when I am attempting to call the method to register my device to Azures notification hub.
The line im calling that throws the error is:
await App.MobileService.GetPush().RegisterAsync(channel.Uri);
and the error thrown is:
The type name 'MobileService' does not exist in the type 'App'
I have the NuGet package Microsoft.WindowsAzure.MobileServices installed but apparently this doesn't contain the definition.
I am following the following guide to setup my push notifications (Under the section "Add push notifications to your app"):
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-push/
I've also looked up how to do this on other sites and I don't see much difference to the instructions, nor do I see what I might be missing...
Anyhow if anyone has any ideas what package or reference I might be missing (or what else might be wrong with that call) I'd appreciate the help! Thanks!
In case anyone runs into this issue I solved this problem adding:
public static MobileServiceClient MobileService = new MobileServiceClient(Utilities.Constants.ApplicationURL, Utilities.Constants.ApplicationKey);
and updating my call like so:
await MobileService.GetPush().RegisterNativeAsync(channelUri);
Hope this helps!

Resources