mirror of
https://github.com/Ujwal223/FocusGram.git
synced 2026-04-03 18:02:20 +02:00
fixed external redirect on instagram m's settings. fixed bug where it opened app session instead of reel session. hided vertical scroll bar. removed custom bottom bar. fixed bug where it wasnt showing searchbar in /explore. FIXED/ADDED/IMPROVED A LOT MORE THINGS. Ready for Release
75 lines
2.2 KiB
Dart
75 lines
2.2 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
|
|
class NotificationService {
|
|
static final NotificationService _instance = NotificationService._internal();
|
|
factory NotificationService() => _instance;
|
|
NotificationService._internal();
|
|
|
|
final FlutterLocalNotificationsPlugin _notificationsPlugin =
|
|
FlutterLocalNotificationsPlugin();
|
|
|
|
Future<void> init() async {
|
|
const AndroidInitializationSettings initializationSettingsAndroid =
|
|
AndroidInitializationSettings('@mipmap/ic_launcher');
|
|
|
|
const DarwinInitializationSettings initializationSettingsIOS =
|
|
DarwinInitializationSettings(
|
|
requestAlertPermission: false,
|
|
requestBadgePermission: false,
|
|
requestSoundPermission: false,
|
|
);
|
|
|
|
const InitializationSettings initializationSettings =
|
|
InitializationSettings(
|
|
android: initializationSettingsAndroid,
|
|
iOS: initializationSettingsIOS,
|
|
);
|
|
|
|
await _notificationsPlugin.initialize(
|
|
settings: initializationSettings,
|
|
onDidReceiveNotificationResponse: (details) {
|
|
// Handle notification tap
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> showNotification({
|
|
required int id,
|
|
required String title,
|
|
required String body,
|
|
}) async {
|
|
const AndroidNotificationDetails androidDetails =
|
|
AndroidNotificationDetails(
|
|
'focusgram_channel',
|
|
'FocusGram Notifications',
|
|
channelDescription: 'Notifications for FocusGram sessions and alerts',
|
|
importance: Importance.max,
|
|
priority: Priority.high,
|
|
showWhen: true,
|
|
);
|
|
|
|
const DarwinNotificationDetails iosDetails = DarwinNotificationDetails(
|
|
presentAlert: true,
|
|
presentBadge: true,
|
|
presentSound: true,
|
|
);
|
|
|
|
const NotificationDetails platformDetails = NotificationDetails(
|
|
android: androidDetails,
|
|
iOS: iosDetails,
|
|
);
|
|
|
|
try {
|
|
await _notificationsPlugin.show(
|
|
id: id,
|
|
title: title,
|
|
body: body,
|
|
notificationDetails: platformDetails,
|
|
);
|
|
} catch (e) {
|
|
debugPrint('Notification error: $e');
|
|
}
|
|
}
|
|
}
|