@@ -8,7 +8,6 @@ import 'package:logging/logging.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:stream_chat/src/api/retry_policy.dart';
|
||||
import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/channel_model.dart';
|
||||
import 'package:stream_chat/src/models/own_user.dart';
|
||||
import 'package:stream_chat/version.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@@ -460,10 +459,12 @@ class Client {
|
||||
|
||||
_connectionStatusHandler = (ConnectionStatus status) async {
|
||||
_wsConnectionStatus = status;
|
||||
handleEvent(Event(
|
||||
type: EventType.connectionChanged,
|
||||
online: status == ConnectionStatus.connected,
|
||||
));
|
||||
handleEvent(
|
||||
Event(
|
||||
type: EventType.connectionChanged,
|
||||
online: status == ConnectionStatus.connected,
|
||||
),
|
||||
);
|
||||
|
||||
if (status == ConnectionStatus.connected &&
|
||||
state.channels?.isNotEmpty == true) {
|
||||
|
||||
@@ -17,10 +17,10 @@ dependencies:
|
||||
async: ^2.4.1
|
||||
rxdart: ^0.24.1
|
||||
collection: ^1.14.12
|
||||
pedantic: ^1.9.2
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^1.10.0
|
||||
json_serializable: ^3.3.0
|
||||
test: ^1.15.7
|
||||
mockito: ^4.1.1
|
||||
pedantic: ^1.9.2
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:example/routes/app_routes.dart';
|
||||
import 'package:example/routes/routes.dart';
|
||||
import 'package:example/stream_version.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
|
||||
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';
|
||||
|
||||
import 'choose_user_page.dart';
|
||||
import 'main.dart';
|
||||
import 'notifications_service.dart';
|
||||
|
||||
class AdvancedOptionsPage extends StatefulWidget {
|
||||
@override
|
||||
@@ -287,10 +280,6 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
||||
userToken,
|
||||
);
|
||||
|
||||
if (!kIsWeb) {
|
||||
initNotifications(client);
|
||||
}
|
||||
|
||||
final secureStorage = FlutterSecureStorage();
|
||||
secureStorage.write(
|
||||
key: kStreamApiKey,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'package:example/stream_version.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'notifications_service.dart';
|
||||
import 'routes/routes.dart';
|
||||
|
||||
const kStreamApiKey = 'STREAM_API_KEY';
|
||||
@@ -187,10 +185,6 @@ class ChooseUserPage extends StatelessWidget {
|
||||
key: kStreamToken,
|
||||
value: token,
|
||||
);
|
||||
|
||||
if (!kIsWeb) {
|
||||
initNotifications(client);
|
||||
}
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
Routes.HOME,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:example/chat_info_screen.dart';
|
||||
import 'package:example/choose_user_page.dart';
|
||||
@@ -41,9 +40,6 @@ void main() async {
|
||||
User(id: userId),
|
||||
token,
|
||||
);
|
||||
if (!kIsWeb) {
|
||||
initNotifications(client);
|
||||
}
|
||||
}
|
||||
|
||||
runApp(MyApp(client));
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ flutter:
|
||||
- animations/
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
mockito: ^4.1.3
|
||||
pedantic: ^1.9.2
|
||||
pedantic: ^1.9.2
|
||||
@@ -20,4 +20,5 @@ dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
fake_async: ^1.1.0
|
||||
pedantic: ^1.9.2
|
||||
|
||||
Reference in New Issue
Block a user