@@ -1,8 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:example/main.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter_apns/flutter_apns.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'
|
||||
hide Message;
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
@@ -34,42 +29,3 @@ void showLocalNotification(Event event) async {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future backgroundHandler(Map<String, dynamic> notification) async {
|
||||
print('new notification ${notification}');
|
||||
// final messageId = notification['data']['id'];
|
||||
//
|
||||
// final notificationData = await NotificationService.getAndStoreMessage(
|
||||
// messageId: messageId,
|
||||
// storeMessageHandler: (messageResponse) {
|
||||
// return chatPersistentClient.updateChannelState(
|
||||
// ChannelState(
|
||||
// messages: [messageResponse.message],
|
||||
// channel: messageResponse.channel,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
//
|
||||
// showLocalNotification(
|
||||
// notificationData.message,
|
||||
// notificationData.channel,
|
||||
// );
|
||||
}
|
||||
|
||||
void initNotifications(Client client) {
|
||||
final connector = createPushConnector();
|
||||
connector.configure(
|
||||
onBackgroundMessage: backgroundHandler,
|
||||
);
|
||||
|
||||
connector.requestNotificationPermissions();
|
||||
connector.token.addListener(() {
|
||||
if (connector.token.value != null) {
|
||||
client.addDevice(
|
||||
connector.token.value,
|
||||
Platform.isAndroid ? PushProvider.firebase : PushProvider.apn,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user