v.1.0.10
This commit is contained in:
parent
895fe0d022
commit
3cd584436b
@ -1,5 +1,8 @@
|
|||||||
Workout Test and Diet 4 You Common Util Functions
|
Workout Test and Diet 4 You Common Util Functions
|
||||||
|
|
||||||
|
Version 1.0.10
|
||||||
|
Firebase FCM for web
|
||||||
|
|
||||||
Version 1.0.9
|
Version 1.0.9
|
||||||
Firebase web config
|
Firebase web config
|
||||||
|
|
||||||
|
@ -33,49 +33,70 @@ class FirebaseApi with logger.Logging {
|
|||||||
|
|
||||||
// Define an async function to initialize FlutterFire
|
// Define an async function to initialize FlutterFire
|
||||||
Future<void> initializeFlutterFire() async {
|
Future<void> initializeFlutterFire() async {
|
||||||
try {
|
try {
|
||||||
// Wait for Firebase to initialize and set `_initialized` state to true
|
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
options: const FirebaseOptions(
|
options: const FirebaseOptions(
|
||||||
apiKey: "AIzaSyBLn7Bz73Z1hB-OhqphBDsskOyGmpI7J8E",
|
apiKey: "AIzaSyBLn7Bz73Z1hB-OhqphBDsskOyGmpI7J8E",
|
||||||
authDomain: "diet4you-cb540.firebaseapp.com",
|
authDomain: "diet4you-cb540.firebaseapp.com",
|
||||||
projectId: "diet4you-cb540",
|
projectId: "diet4you-cb540",
|
||||||
storageBucket: "diet4you-cb540.appspot.com",
|
storageBucket: "diet4you-cb540.appspot.com",
|
||||||
messagingSenderId: "534189506381",
|
messagingSenderId: "534189506381",
|
||||||
appId: "1:534189506381:web:e885436c9be71ab4998104",
|
appId: "1:534189506381:web:e885436c9be71ab4998104",
|
||||||
measurementId: "G-9YY4B98J99"
|
measurementId: "G-9YY4B98J99"
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
|
}
|
||||||
|
} on Exception catch(e) {
|
||||||
|
Sentry.captureException(e);
|
||||||
|
log("Error in Firebase init: $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
appleSignInAvailable = await SignInWithApple.isAvailable();
|
appleSignInAvailable = await SignInWithApple.isAvailable();
|
||||||
|
|
||||||
|
if (kIsWeb) {
|
||||||
|
final fcmToken = await FirebaseMessaging.instance.getToken(vapidKey: "BKqkxyTqlGGI6m4gFLa-fFu9kYflyCbLkDKRKihWLqhDyR8oy1ymGzbk9lGcSDW1fd7XZiN2XYA2sDF8yjHdFPg");
|
||||||
|
FirebaseMessaging.instance.onTokenRefresh
|
||||||
|
.listen((fcmToken) {
|
||||||
|
|
||||||
|
|
||||||
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
|
// Note: This callback is fired at each app startup and whenever a new
|
||||||
alert: true, // Required to display a heads up notification
|
// token is generated.
|
||||||
badge: true,
|
log('FCM token generated');
|
||||||
sound: true,
|
|
||||||
);
|
|
||||||
firebaseRegToken = await FirebaseMessaging.instance.getToken();
|
|
||||||
Cache().firebaseMessageToken = firebaseRegToken;
|
|
||||||
log("FirebaseMessaging token $firebaseRegToken");
|
|
||||||
|
|
||||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
})
|
||||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
.onError((err) {
|
||||||
log('Got a message whilst in the foreground!');
|
Sentry.captureException(err);
|
||||||
log('Message data: ${message.data}');
|
log("Error initializing Firebase Messaging for Web $err");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
|
||||||
|
alert: true, // Required to display a heads up notification
|
||||||
|
badge: true,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
firebaseRegToken = await FirebaseMessaging.instance.getToken();
|
||||||
|
Cache().firebaseMessageToken = firebaseRegToken;
|
||||||
|
log("FirebaseMessaging token $firebaseRegToken");
|
||||||
|
|
||||||
if (message.notification != null) {
|
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
||||||
log('Message also contained a notification: ${message.notification}');
|
|
||||||
|
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||||
|
log('Got a message whilst in the foreground!');
|
||||||
|
log('Message data: ${message.data}');
|
||||||
|
|
||||||
|
if (message.notification != null) {
|
||||||
|
log('Message also contained a notification: ${message.notification}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
Sentry.captureException(e);
|
||||||
|
log("Error initializing Firebase Messaging $e");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Set `_error` state to true if Firebase initialization fails
|
|
||||||
Sentry.captureException(e);
|
|
||||||
log("Error initializing Firebase");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: workouttest_util
|
name: workouttest_util
|
||||||
description: Workout Test app and web functions.
|
description: Workout Test app and web functions.
|
||||||
version: 1.0.8
|
version: 1.0.10
|
||||||
homepage:
|
homepage:
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Loading…
Reference in New Issue
Block a user