Skip to content

Commit

Permalink
chore: conditionlly add firebase options
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-Zimmerman committed Feb 10, 2025
1 parent 1fccc3a commit 38b700a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AppInitializer {

/// Firebase
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
options: kIsWeb ? DefaultFirebaseOptions.currentPlatform : null,
);
if (!kIsWeb && Platform.isAndroid) {
FirebaseMessaging.onBackgroundMessage(
Expand Down Expand Up @@ -171,7 +171,7 @@ var fromBackground = false;
@pragma('vm:entry-point')
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
options: kIsWeb ? DefaultFirebaseOptions.currentPlatform : null,
);
logger.i('Handling a background message ${message.toMap().toString()}');
await NotificationService.showNotification(message);
Expand Down
4 changes: 3 additions & 1 deletion lib/model/profile_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class Profile {
if (defaultTargetPlatform == TargetPlatform.android) {
// If no apps are initialized, initialize one now.
if (Firebase.apps.isEmpty) {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await Firebase.initializeApp(
options: kIsWeb ? DefaultFirebaseOptions.currentPlatform : null,
);
}
token = (await FirebaseMessaging.instance.getToken())!;
} else if (Platform.isIOS) {
Expand Down

0 comments on commit 38b700a

Please sign in to comment.