add android push customization
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.example.example
|
||||
|
||||
import com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin
|
||||
import com.example.path_provider.PathProviderPlugin
|
||||
import io.flutter.app.FlutterApplication
|
||||
import io.flutter.plugin.common.PluginRegistry
|
||||
@@ -15,6 +16,8 @@ class Application : FlutterApplication(), PluginRegistrantCallback {
|
||||
}
|
||||
|
||||
override fun registerWith(registry: PluginRegistry?) {
|
||||
FlutterLocalNotificationsPlugin.registerWith(registry?.registrarFor(
|
||||
"com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"))
|
||||
SharedPreferencesPlugin.registerWith(registry?.registrarFor(
|
||||
"io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"))
|
||||
FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user