add android push customization

This commit is contained in:
Salvatore Giordano
2020-03-25 10:10:20 +01:00
parent f4af785d45
commit 4356b4f0ea
2 changed files with 28 additions and 0 deletions
+25
View File
@@ -1,10 +1,35 @@
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
Future<void> _handleBackgroundNotification(
Map<String, dynamic> notification,
) async {
final notificationData = await NotificationService.storeMessage(notification);
final androidPlatformChannelSpecifics = AndroidNotificationDetails(
'Message notifications',
'Message notifications',
'Channel dedicated to message notifications',
importance: Importance.Max,
priority: Priority.High,
);
final androidNotificationOptions = AndroidNotificationOptions(
androidNotificationDetails: androidPlatformChannelSpecifics,
id: notificationData.message.id.hashCode,
title:
'CUSTOM ${notificationData.message.user.name} @ ${notificationData.channel.cid}',
body: notificationData.message.text,
);
await NotificationService.sendNotification(androidNotificationOptions);
}
void main() async {
final client = Client(
's2dxdhpxd94g',
logLevel: Level.INFO,
notificationHandler: _handleBackgroundNotification,
);
await client.setUser(