Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed May 11, 2024
1 parent 6799bda commit e6901db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
32 changes: 11 additions & 21 deletions lib/Backend/firebase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Future<void> initFirebase() async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

FirebaseMessaging messaging = FirebaseMessaging.instance;
messaging.app.setAutomaticDataCollectionEnabled(false);
Firebase.app().setAutomaticDataCollectionEnabled(false);
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
await messaging.subscribeToTopic("newsletter");
final notificationSettings = await messaging.requestPermission(
Expand All @@ -38,10 +38,8 @@ Future<void> initFirebase() async {
fireLogger.info('Message data: ${message.data}');

if (message.notification != null) {
fireLogger.info(
'Message also contained a notification: ${message.notification}');
const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails(
fireLogger.info('Message also contained a notification: ${message.notification}');
const AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails(
'newsletter',
'Newsletter',
channelDescription: 'Notifications from the Tail Company Newsletter',
Expand All @@ -50,8 +48,7 @@ Future<void> initFirebase() async {
enableVibration: false,
enableLights: false,
);
const NotificationDetails notificationDetails =
NotificationDetails(android: androidNotificationDetails);
const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails);
await flutterLocalNotificationsPlugin?.show(
message.notification.hashCode,
message.notification?.title,
Expand All @@ -60,9 +57,8 @@ Future<void> initFirebase() async {
);
}
});
}
catch(e,s) {
fireLogger.shout('error setting up firebase',e,s);
} catch (e, s) {
fireLogger.shout('error setting up firebase', e, s);
}
}

Expand All @@ -75,26 +71,21 @@ FlutterLocalNotificationsPlugin? flutterLocalNotificationsPlugin;
Future<void> initNotificationPlugin() async {
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings("@mipmap/ic_launcher");
const DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings(
defaultPresentSound: false, requestSoundPermission: false);
const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings("@mipmap/ic_launcher");
const DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings(defaultPresentSound: false, requestSoundPermission: false);
const InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
);
await flutterLocalNotificationsPlugin?.initialize(
initializationSettings,
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse,
onDidReceiveBackgroundNotificationResponse:
onDidReceiveBackgroundNotificationResponse,
onDidReceiveBackgroundNotificationResponse: onDidReceiveBackgroundNotificationResponse,
);
}

//Foreground
void onDidReceiveNotificationResponse(
NotificationResponse notificationResponse) async {
void onDidReceiveNotificationResponse(NotificationResponse notificationResponse) async {
final String? payload = notificationResponse.payload;
if (notificationResponse.payload != null) {
fireLogger.info('notification payload: $payload');
Expand All @@ -103,8 +94,7 @@ void onDidReceiveNotificationResponse(

//background
@pragma('vm:entry-point')
void onDidReceiveBackgroundNotificationResponse(
NotificationResponse notificationResponse) {
void onDidReceiveBackgroundNotificationResponse(NotificationResponse notificationResponse) {
final String? payload = notificationResponse.payload;
if (notificationResponse.payload != null) {
fireLogger.info('notification payload: $payload');
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/pages/developer/developer_pincode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class _DeveloperPincodeState extends State<DeveloperPincode> {
Widget build(BuildContext context) {
return Scaffold(
body: ScreenLock(
title: LottieLazyLoad(
title: const LottieLazyLoad(
asset: 'assets/tailcostickers/tgs/TailCoStickers_file_144834344.tgs',
renderCache: true,
width: 80,
Expand Down

0 comments on commit e6901db

Please sign in to comment.