You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Use the correct listeners for messages
FirebaseMessaging.onMessage.listen((message) {
if (Platform.isIOS) {
foregroundMessage();
}
showPushNotification(message);
});
}
void initLocalNotifications() async {
var androidInitializationSettings =
const AndroidInitializationSettings('@mipmap/ic_launcher');
var iosInitializationSettings = const DarwinInitializationSettings();
for (String key in keys) {
if (key == 'uid') {
continue;
}
List<String> messages = prefs.getStringList(key) ?? [];
allMessages[key] = messages;
}
return allMessages;
}
}
I am trying to show grouped notification like whatsapp but issue is that when single notification it is working fine but when second user notification comes means when it grouped the status bar icon disappeared else notification shows in notification centre .
Android
Please help me resolve this issue
The text was updated successfully, but these errors were encountered:
class PushNotificationService {
final ScreenshotController screenshotController = ScreenshotController();
final String projectId = 'flirt-to-go';
final String serviceAccountJsonPath = 'assets/service_account.json';
AndroidNotificationChannel senderChannel = AndroidNotificationChannel(
'FlirtToGo_Sender_Channel',
'FlirtToGo Individual Notifications',
importance: Importance.max,
);
AndroidNotificationChannel groupChannel = AndroidNotificationChannel(
'FlirtToGo_Group_Channel',
'FlirtToGo Group Summary Notifications',
importance: Importance.low,
);
FirebaseMessaging messaging = FirebaseMessaging.instance;
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
Future foregroundMessage() async {
await FirebaseMessaging.instance
.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
}
Future _getOauth2AccessToken() async {
var scopes = ['https://www.googleapis.com/auth/firebase.messaging'];
final jsonString = await rootBundle.loadString(serviceAccountJsonPath);
var credentials = ServiceAccountCredentials.fromJson(jsonString);
var client = await clientViaServiceAccount(credentials, scopes);
return (client.credentials.accessToken).data;
}
Future requestNotificationPermission() async {
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: true,
badge: true,
carPlay: true,
criticalAlert: true,
provisional: true,
sound: true,
);
}
Future getDeviceToken() async {
String? token = await messaging.getToken();
return token!;
}
Future sendPushNotificationApi(String body) async {
try {
String accessToken = await _getOauth2AccessToken();
}
void serviceInit() async {
initLocalNotifications();
}
void initLocalNotifications() async {
var androidInitializationSettings =
const AndroidInitializationSettings('@mipmap/ic_launcher');
var iosInitializationSettings = const DarwinInitializationSettings();
}
Future handleMessage(RemoteMessage message) async {
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (message.data['type'] == 'm') {
String endUserJson = message.data['endUser'];
Map<String, dynamic> endUserMap = jsonDecode(endUserJson);
}
Future groupNotificationOverAll() async {
Map<String, List> allMessages = await _retrieveAllMessagesGrouped();
}
Future groupNotificationBySender({
required RemoteMessage message,
}) async {
Uint8List? imageBytes;
Person person;
AndroidNotificationDetails androidDetails;
}
Future<Uint8List?> _captureCombinedIcon(UserDataModel endUser) async {
final BuildContext context = Get.context!;
}
Future showPushNotification(RemoteMessage message) async {
await groupNotificationBySender(message: message);
await groupNotificationOverAll();
}
Future setupInteractMessage() async {
RemoteMessage? initialMessage =
await FirebaseMessaging.instance.getInitialMessage();
}
Future _saveMessagesForUser(String endUserId, String message) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List messages = prefs.getStringList(endUserId) ?? [];
messages.add(message);
await prefs.setStringList(endUserId, messages);
}
Future clearMessagesForUser(String endUserId) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.remove(endUserId);
await _flutterLocalNotificationsPlugin.cancel(endUserId.hashCode);
}
Future<List> _retrieveStoredMessagesForUser(String endUserId) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getStringList(endUserId) ?? [];
}
Future<Map<String, List>> _retrieveAllMessagesGrouped() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
Map<String, List> allMessages = {};
Set keys = prefs.getKeys();
}
}
I am trying to show grouped notification like whatsapp but issue is that when single notification it is working fine but when second user notification comes means when it grouped the status bar icon disappeared else notification shows in notification centre .
Android
Please help me resolve this issue
The text was updated successfully, but these errors were encountered: