Skip to content

Commit b9b1a97

Browse files
committed
Revert removal of firebase_options.dart
Someone using the example app and is only interested in iOS may not have flutterfire installed hence this file may not be generated. To prevent the app from crashing in that case, we provide this
1 parent 176292c commit b9b1a97

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// File generated by FlutterFire CLI.
2+
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
3+
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
4+
import 'package:flutter/foundation.dart'
5+
show defaultTargetPlatform, kIsWeb, TargetPlatform;
6+
7+
/// Default [FirebaseOptions] for use with your Firebase apps.
8+
///
9+
/// Example:
10+
/// ```dart
11+
/// import 'firebase_options.dart';
12+
/// // ...
13+
/// await Firebase.initializeApp(
14+
/// options: DefaultFirebaseOptions.currentPlatform,
15+
/// );
16+
/// ```
17+
class DefaultFirebaseOptions {
18+
static FirebaseOptions get currentPlatform {
19+
if (kIsWeb) {
20+
throw UnsupportedError(
21+
'DefaultFirebaseOptions have not been configured for web - '
22+
'you can reconfigure this by running the FlutterFire CLI again.',
23+
);
24+
}
25+
switch (defaultTargetPlatform) {
26+
case TargetPlatform.android:
27+
throw UnsupportedError(
28+
'DefaultFirebaseOptions have not been configured for android - '
29+
'you can reconfigure this by running the FlutterFire CLI again.',
30+
);
31+
case TargetPlatform.iOS:
32+
throw UnsupportedError(
33+
'DefaultFirebaseOptions have not been configured for ios - '
34+
'you can reconfigure this by running the FlutterFire CLI again.',
35+
);
36+
case TargetPlatform.macOS:
37+
throw UnsupportedError(
38+
'DefaultFirebaseOptions have not been configured for macos - '
39+
'you can reconfigure this by running the FlutterFire CLI again.',
40+
);
41+
case TargetPlatform.windows:
42+
throw UnsupportedError(
43+
'DefaultFirebaseOptions have not been configured for windows - '
44+
'you can reconfigure this by running the FlutterFire CLI again.',
45+
);
46+
case TargetPlatform.linux:
47+
throw UnsupportedError(
48+
'DefaultFirebaseOptions have not been configured for linux - '
49+
'you can reconfigure this by running the FlutterFire CLI again.',
50+
);
51+
default:
52+
throw UnsupportedError(
53+
'DefaultFirebaseOptions are not supported for this platform.',
54+
);
55+
}
56+
}
57+
}

examples/push_notifications/lib/main.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import 'firebase_options.dart';
55

66
Future<void> main() async {
77
WidgetsFlutterBinding.ensureInitialized();
8-
await Firebase.initializeApp(
9-
options: DefaultFirebaseOptions.currentPlatform,
10-
);
8+
9+
if (Platform.isAndroid) {
10+
await Firebase.initializeApp(
11+
options: DefaultFirebaseOptions.currentPlatform,
12+
);
13+
}
1114

1215
await Talk.registerPushNotificationHandlers(
1316
androidChannel: const AndroidChannel(

0 commit comments

Comments
 (0)