Could not configure Firebase InstanceID - ios

hi I'm trying to include firebase in my app and followed the documentation, when I'm trying to do google sign in, Could not configure Firebase InstanceID error occurs .please advice how to overcome this error

There are two things to check (and hopefully, one will fix it for you):
Make sure your BundleIdentifier is exactly the same in your Firebase project as it is in your Xcode, i.e. com.[yourcompany].[yourappname]
Make sure you got the latest GoogleService-Info.plist file. Go to Firebase Console -> Settings -> Your Application - there will be a blue button to the right that lets you download new configuration file
That solved it for me.

Bug Details
As of version 3.13.0, there appears to be a bug in the Firebase/Core SDK.
I added a symbolic breakpoint at -[FIRInstanceID(FIRApp) configureInstanceIDWithOptions:app:] and stepped though the assembly.
It appears that FIRApp.configure() is ignoring the IS_GCM_ENABLED flag in the GoogleServices-Info.plist and tries to configure GCM regardless of the flag's state. In my case, because my project does not use GCM, the app would crash because there was no GCM_SENDER_ID in the plist.
Workaround
Add a dummy value (i.e. 123456789012) for GCM_SENDER_ID within the GoogleService-Info.plist file. This will allow the application to configure successfully.

You have to add your project which is created on
https://developers.google.com/mobile/add?platform=ios or fire base console into your Firebase dashboard.
Now you can download GoogleService-Info.plist from Firebase and import into your project.

I setup Firebase in code using FIROptions. In my case, I was missing gcmSenderID, fixing it then it works

Firebase DevRel here. This should be an error, unless you enabled gcm, you shouldn't go through instanceid setup. Filed internally.
For now, the workaround is manually changing "IS_GCM_ENABLED" to "NO" in your "GoogleService-Info.plist" file

I was getting this error as I didn't have my GoogleService-Info.plist in my Test folder as well. ( if you are using TDD)
As of the latest Firebase Core 3.16.0 - I seem to need to include it in my main project as well as copying a version into my Test Root.

This also happens when you shift your google SDK integration from one account to another and don't edit the API keys on application side.Make sure when you shift from one google account to another, you re-visit all the SDK guides again like FCM, Google Sign-in etc and make sure you are using new API keys (client_id, URI Scheme) in application.

Related

Can't get debug token for Firebase App Check for my Flutter iOS App

So I recently started setting up app check for my existing Flutter project (for both android and iOS platforms). I've had no problem with android's "Play Integrity", got the necessary debug token, and can successfully send and retrieve data to/from firestore (app check for firestore is currently enforced for my project).
The problem is, I can not get such a debug key for my iOS app. I will list the sources I've used and what I've tried so far.
I have firebase_app_check: ^0.1.1+8 installed via pubspec.yaml
I also added pod 'FirebaseAppCheck' to my Podfile
I have the necessary initialization code in my main.dart: await FirebaseAppCheck.instance.activate(...);
For "DeviceCheck", I am using THE SAME private key that I am using
for "Sign in With Apple" (which I have implemented successfully). I
have also enabled the checkbox for DeviceCheck in the settings of
that private key (in Apple Developer).
For my App ID (Apple Developer > Identifiers > App IDs), I have also
enabled the checkbox for "App Attest".
I have put "-FIRDebugEnabled" as an argument passed on launch in
XCode > Product > Scheme > Edit Scheme.
I always uninstall my app from my iOS simulator (iOS 16.2) or real device (iOS 16.1.2),
before trying again, because I have read across multiple forums that
the debug token only gets printed to the output the first time you
run your app.
I have also added these 4 lines of code in my AppDelegate.swift from here:
#if DEBUG
let providerFactory = AppCheckDebugProviderFactory()
AppCheck.setAppCheckProviderFactory(providerFactory)
#endif
Official firebase docs "iOS+ (App Attest)":
I have NOT copied ANY code from this page of the official docs, as I assume it's for native iOS apps only, and not for flutter, and I don't know where exactly I would have to put that code. I have only added the pod dependency and run pod install.
I don't have a .entitlements file.
So after all those steps, I'm apparently supposed to expect to find a debug token in my run output, as in:
Yet the only relevant output I can find is the following:
Runner[72719:33546579] 10.3.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. (com.apple.devicecheck.error error 1.)'
If it matters:
I have NOT YET uploaded my iOS app to apple developer, app store connect or whatever (I'm not yet familiar with the process of publishing to the app store).
Neither have I uploaded my android app to Google Play console or created an app there (for this project).
Don't tell me anything about firestore rules. I already had that set up long ago, and everything worked just fine before I started integrating App Check.
Don't recommend any 3rd party plugins to me, I will only use official ones.
The firebase documentation says:
Tip: Confirm in your Xcode project's build settings that it passes the DEBUG flag to the Swift compiler
Try removing the '#if DEBUG' and '#endif' and run the app.
If it works, it mean you have missed that step
I was not able to find that build setting, so i just removed those lines from the AppDelegate, but i need to keep in mind to remove the other 2 lines while building the release mode
See this answer on the flutterfire Github issues page. Basically, call setAppCheckProviderFactory before GeneratedPluginRegistrant.register(with: self) in the app delegate file. I was investigating the same issue and it fixed it for me (the debug token was instantly printed out in Xcode's debug output). Hope it helps you as well!

Why does flutterfire configure not replace my old GoogleService-Info.plist file?

When I first run flutterfire configure in my flutter app, 4 files were generated. firebase_options.dart, google-services.json, firebase_app_id_file.json and GoogleServices-Info.plist.
When I tried to use flutterfire configure again to link my app to a development version of my app (following this thread), I was only prompted to change 3 of the files like this:
The google-services.json file already exists but for a different Firebase project (betacentre-dev). Do you want to replace it with Firebase project thinking-digit-343408? · yes
After selecting yes for all of them, only GoogleService-Info.plist was unchanged, yet it is clearly crucial for firebase to work (since flutterfire configure added it in the first place, and it is referenced in this guide and also this guide, and it contains identifiers for my firebase project, and my app still communicates with the original project).
Is this a bug? Why is it behaving this way?

How can I get the 'facebookScheme' for iOS in an Expo project?

Expo documentation on expo-facebook says I need to add facebookScheme setting to my app.json file.
To acquire it, the documentation says for me to access the Facebook documentation.
The Facebook documentation says I need to configure a bunch of stuff which requires a Xcode project. For example, configure Info.plist file, or install some dependencies which require Cocoapods.. etc.
But Expo does not expose this file to me, it's an Expo project after all!
What do I do here then? Do I need to associate this Expo project to an Xcode project, somehow? Do I need to eject from Expo?
Just to add some context (which might be relevant or not), the main reason I'm asking this is because when I try to login using Facebook on iOS, my app simply crashes (a SIGABRT error)! I suspect it is because of this missing facebookScheme field.
Thank you
For crystal clarity because I'm even dumber than OP, you gotta get whatever the string value is after CFBundleURLSchemes. Literally put the following in your app.json:
{
"expo": {
"facebookScheme": "fb<probably_your_fb_appId_here>",
"facebookAppId": "<definitely_your_fb_appId_here>",
"facebookDisplayName": "<your_app_name_here>",
"facebookAutoLogAppEventsEnabled": false,
"facebookAdvertiserIDCollectionEnabled": false
},
"name": "external_login"
}
For a fully functioning app, you're gonna need the other values that come with the app.json too.
So, I'm dumb.
I thought I had to follow the steps mentioned on FB's documentation, but that was not it. I simply had to access it, go straight to step 4 and copy the values CFBundleURLSchemes (which is the facebookScheme I was looking for), FacebookAppID and FacebookDisplayName, then paste then inside app.json file.
Remember to be logged in with your FB dev account and select your FB app on step 1 inside FB's documentation mentioned above.
This solved the issue about my app crashing as soon as I clicked the FB button.

Why is Firebase Analytics disabled for my iOS app?

I've written an app which uses Firebase. I have installed it properly, I believe, and I've done the [FIRApp configure]; in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I've also added the debug arguments for the project scheme to see what's happening. Firebase seems to be working as intended, except that it keeps telling me that Firebase analytics is disabled.
My log in Xcode:
Firebase screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
Configuring the default app.
InstanceID library version 2.0.5
Debug mode is on
Firebase Analytics v.40004000 started
Firebase Analytics disabled
Tracking view controller. Class, ID: MainViewController
Screen view event not logged. App is not active.
Firebase Analytics is disabled. Event not logged
So Firebase obviously works, but it won't let me send any events, custom or otherwise. I can't find anyone else with this issue. I believe my project is correct set up in console.firebase.com but it simply won't send any data there. I have downloaded and added my GoogleServices-Info.plist file. My app is targeted iOS9 and above, and I'm using Objective-C.
I've followed this guide: https://firebase.google.com/docs/ios/setup#add_firebase_to_your_app
Edit
My project is old, before Firebase existed. So I imported it from Google Cloud Platform. I'm thinking this might be the issue. I tried creating an entirely new project on another account and then added a completely new app. Firebase worked as intended. Anyone experienced any issues when migrating from Google Cloud Platform?
So I finally found the issue. After creating a new project entirely and moving my app to that project it still didn't work. So I started to scan through the entire project for anything that might cause Firebase to disable logging.
Turns out FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED was set to YES in the Info.plist file. I have no idea why, since the project didn't use Firebase at all until I started to add it. Hope this blunder helps someone else with the same issue.
TL;DR
try update Firebase SDK to latest version.
Just incase anyone see this thread. We have met a similar situation like #ClockWise met. however, after trying tweak with info.plist. it turn's out the reason was the version of SDK.
We use to have version 6.11.0(firebase), and 6.1.3(firebase analytics), after running pod update to update sdk to latest version(6.21.0), it works properly, debug view is working, and we can see the events in firebase dashboard.

GoogleService-Info.plist not created

I'm upgrading from an earlier version of Google Analytics for my iOS app and when I follow the instructions here, I click the button to create a configuration file and nothing happens. Anyone else experience this? Is there a default GoogleService-Info.plist that I can use and customize?
Thanks!
Seems to be a bug on their site. It worked for me 2 weeks ago. However you have already found Googles Guide - the config file does not contain any complicated settings, however you can download the Sample Apps and get your initial GoogleService-Info.plist file from there:
pod try Google
from
https://developers.google.com/maps/documentation/ios-sdk/code-samples#try-the-sdk-demos-using-cocoapods
Steps for getting configuration if your first time login to google developer account.
1. open google developer console.
2. login to developer console.
3. create project with valid name.
4. then goto the API section & enable GCM API.
5. Then get the configuration file.
Thanks for the suggestions, looks like they would work for others. Unfortunately, I just couldn't get Cocoa Pods to upgrade the analytics, so I switched tactics and used the sdk directly. This worked fine, hopefully others have better luck!

Resources