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
@@ -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"))
+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(