DefaultFirebaseOptions are not supported for this platform
barbalex opened this issue ยท 9 comments
After running into #19 and having to install the cli, create firebase_options.dart and add options: DefaultFirebaseOptions.currentPlatform
when initializing the firebase App, I now run into this error:
Exception has occurred.
UnsupportedError (Unsupported operation: DefaultFirebaseOptions are not supported for this platform.)
Could this have something to do with the fact that windows can't be added as a platform on https://console.firebase.google.com?
Windows and Linux aren't supported in Firebase Console.
Currently since the desktop packages under the hood use Identity Platform REST API, Web configurations can be used, but considering the CLI seems to be reading the current platform so it throws this exception.
@Salakar this is interesting case to think about for FF desktop
Yep the current recommendation is to select web as a platform to generate the DefaultFirebaseOptions for, and then instead of DefaultFirebaseOptions.currentPlatform
you can use DefaultFirebaseOptions.web
Yep the current recommendation is to select web as a platform to generate the DefaultFirebaseOptions for, and then instead of
DefaultFirebaseOptions.currentPlatform
you can useDefaultFirebaseOptions.web
Can you elaborate on this?
My current Firebase initialization looks like this:
// Init Firebase
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: Platform.isLinux ? DefaultFirebaseOptions.web : DefaultFirebaseOptions.currentPlatform,
);
Or even more flexible:
bool needsWeb = Platform.isLinux | Platform.isWindows;
await Firebase.initializeApp(
options: needsWeb
? DefaultFirebaseOptions.web
: DefaultFirebaseOptions.currentPlatform,
);
Just to clarify, macOS is included, as mentioned in the README
the plugin will override macOS implementation as it's currently being used for development purposes.
Hi, all, tried the solutions mentioned in this solution, but it does not work for flutter apps (for linux) with flutter version (3.10.6 - stable), firebase_core (2.15.0) and cloud_firestore (4.8.4).
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0 FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:210)
#1 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29)
#2 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:73)
#3 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43)
Just wondering any timeline to officially support this for Linux/Windows?
Cheers
Have you taken a look at this package?
I tried with firebase_core_desktop, the UI can be displayed on Linux, however, it failed to fetch data from firestore. the function snapshots() won't be able to be called. See the message below:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method Query#snapshots on channel plugins.flutter.io/firebase_firestore)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)
#1 MethodChannelQuery.snapshots. (package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart:150:28)