Compare commits
No commits in common. "51efc56ced3bcd1795d1715c370418573095fd6f" and "2b0fa4b5785fa8d56727707783279b6690678fef" have entirely different histories.
51efc56ced
...
2b0fa4b578
@ -38,10 +38,6 @@ class ListenNotification extends StreamUseCase<NoParam, RemoteNotification> {
|
|||||||
if (notificationStreamResponse.isOk) {
|
if (notificationStreamResponse.isOk) {
|
||||||
notificationStream = notificationStreamResponse.ok;
|
notificationStream = notificationStreamResponse.ok;
|
||||||
} else if (notificationStreamResponse.isErr) {
|
} else if (notificationStreamResponse.isErr) {
|
||||||
if (notificationStreamResponse.err! is UnimplementedError) {
|
|
||||||
return Err(notificationStreamResponse.err!);
|
|
||||||
}
|
|
||||||
|
|
||||||
final notificationBackgroundStreamResponse =
|
final notificationBackgroundStreamResponse =
|
||||||
await _notificationRepository.onNotificationBackground();
|
await _notificationRepository.onNotificationBackground();
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ import 'package:firebase_messaging/firebase_messaging.dart'
|
|||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:wyatt_cloud_messaging_bloc_base/wyatt_cloud_messaging_bloc.dart';
|
import 'package:wyatt_cloud_messaging_bloc_base/wyatt_cloud_messaging_bloc.dart';
|
||||||
|
|
||||||
typedef CloudMessagingStreamController = StreamController<RemoteNotification>;
|
|
||||||
|
|
||||||
class CloudMessagingFirebaseDataSource extends CloudMessagingRemoteDataSource {
|
class CloudMessagingFirebaseDataSource extends CloudMessagingRemoteDataSource {
|
||||||
final FirebaseMessaging _firebaseMessagingInstance =
|
final FirebaseMessaging _firebaseMessagingInstance =
|
||||||
FirebaseMessaging.instance;
|
FirebaseMessaging.instance;
|
||||||
@ -20,36 +18,8 @@ class CloudMessagingFirebaseDataSource extends CloudMessagingRemoteDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Stream<RemoteNotification>> onNotificationBackground() async {
|
Future<Stream<RemoteNotification>> onNotificationBackground() {
|
||||||
final backgroundStreamController = CloudMessagingStreamController();
|
throw UnimplementedError();
|
||||||
|
|
||||||
Future<void> getLastBackgroundNotification() async {
|
|
||||||
final lastNotification =
|
|
||||||
await _firebaseMessagingInstance.getInitialMessage();
|
|
||||||
if (lastNotification != null) {
|
|
||||||
backgroundStreamController.add(
|
|
||||||
RemoteNotification(
|
|
||||||
title: lastNotification.notification?.title,
|
|
||||||
body: lastNotification.notification?.body,
|
|
||||||
data: lastNotification.data,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen((notification) {
|
|
||||||
backgroundStreamController.add(
|
|
||||||
RemoteNotification(
|
|
||||||
title: notification.notification?.title,
|
|
||||||
body: notification.notification?.body,
|
|
||||||
data: notification.data,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
unawaited(getLastBackgroundNotification());
|
|
||||||
|
|
||||||
return backgroundStreamController.stream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -77,8 +47,8 @@ class CloudMessagingFirebaseDataSource extends CloudMessagingRemoteDataSource {
|
|||||||
iOS: DarwinInitializationSettings(),
|
iOS: DarwinInitializationSettings(),
|
||||||
);
|
);
|
||||||
|
|
||||||
final CloudMessagingStreamController foregroundStream =
|
final StreamController<RemoteNotification> foregroundStream =
|
||||||
CloudMessagingStreamController();
|
StreamController<RemoteNotification>();
|
||||||
|
|
||||||
await _localNotificationInstance.initialize(
|
await _localNotificationInstance.initialize(
|
||||||
initializationSettings,
|
initializationSettings,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user