mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-17 06:20:44 +01:00
feat: Implement fcm_shared_isolate
This commit is contained in:
parent
38e8e1bce1
commit
d730fb5167
@ -79,6 +79,7 @@ build_android_apk:
|
||||
only:
|
||||
- main
|
||||
- tags
|
||||
- krille/fcmsharedisolate
|
||||
|
||||
build_android_appbundle:
|
||||
stage: coverage
|
||||
|
@ -28,7 +28,8 @@ abstract class AppConfig {
|
||||
static const String pushNotificationsChannelName = 'FluffyChat push channel';
|
||||
static const String pushNotificationsChannelDescription =
|
||||
'Push notifications for FluffyChat';
|
||||
static const String pushNotificationsAppId = 'chat.fluffy.fluffychat';
|
||||
static const String pushNotificationsAppId =
|
||||
'chat.fluffy.fluffychat.experimental';
|
||||
static const String pushNotificationsGatewayUrl =
|
||||
'https://janian.de:7023/_matrix/push/v1/notify';
|
||||
static const String pushNotificationsPusherFormat = 'event_id_only';
|
||||
|
@ -1,11 +1,11 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
|
||||
import 'package:fluffychat/app_config.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flushbar/flushbar_helper.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -20,7 +20,7 @@ import 'famedlysdk_store.dart';
|
||||
import 'matrix_locals.dart';
|
||||
|
||||
abstract class FirebaseController {
|
||||
static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
static final FcmSharedIsolate _firebaseMessaging = FcmSharedIsolate();
|
||||
static final FlutterLocalNotificationsPlugin
|
||||
_flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||
static BuildContext context;
|
||||
@ -29,7 +29,7 @@ abstract class FirebaseController {
|
||||
MatrixState matrix, String clientName) async {
|
||||
if (!PlatformInfos.isMobile) return;
|
||||
final client = matrix.client;
|
||||
if (Platform.isIOS) iOS_Permission();
|
||||
//if (Platform.isIOS) iOS_Permission();
|
||||
|
||||
String token;
|
||||
try {
|
||||
@ -134,17 +134,14 @@ abstract class FirebaseController {
|
||||
await _flutterLocalNotificationsPlugin.initialize(initializationSettings,
|
||||
onSelectNotification: goToRoom);
|
||||
|
||||
_firebaseMessaging.configure(
|
||||
_firebaseMessaging.setListeners(
|
||||
onMessage: _onMessage,
|
||||
onBackgroundMessage: _onMessage,
|
||||
onResume: goToRoom,
|
||||
onLaunch: goToRoom,
|
||||
);
|
||||
Logs().i('[Push] Firebase initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
static Future<dynamic> _onMessage(Map<String, dynamic> message) async {
|
||||
static void _onMessage(Map<dynamic, dynamic> message) async {
|
||||
try {
|
||||
final data = message['data'] ?? message;
|
||||
final String roomId = data['room_id'];
|
||||
@ -362,12 +359,12 @@ abstract class FirebaseController {
|
||||
return file.path;
|
||||
}
|
||||
|
||||
static void iOS_Permission() {
|
||||
/*static void iOS_Permission() {
|
||||
_firebaseMessaging.requestNotificationPermissions(
|
||||
IosNotificationSettings(sound: true, badge: true, alert: true));
|
||||
_firebaseMessaging.onIosSettingsRegistered
|
||||
.listen((IosNotificationSettings settings) {
|
||||
Logs().i('Settings registered: $settings');
|
||||
});
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
29
pubspec.lock
29
pubspec.lock
@ -220,6 +220,15 @@ packages:
|
||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
fcm_shared_isolate:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: "19f36c2ad7df214cae34c870f3888e24dac90b86"
|
||||
url: "https://gitlab.com/famedly/libraries/fcm_shared_isolate.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -262,41 +271,27 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
firebase:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.3.0"
|
||||
firebase_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.0+1"
|
||||
version: "0.5.3"
|
||||
firebase_core_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_core_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0"
|
||||
firebase_core_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: firebase_core_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
firebase_messaging:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: firebase_messaging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.0.3"
|
||||
version: "0.2.1+1"
|
||||
flushbar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -20,7 +20,10 @@ dependencies:
|
||||
image_picker: ^0.6.7+21
|
||||
url_launcher: ^5.7.10
|
||||
cached_network_image: ^2.5.0
|
||||
firebase_messaging: ^7.0.3
|
||||
fcm_shared_isolate:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/libraries/fcm_shared_isolate.git
|
||||
ref: main
|
||||
flutter_local_notifications: ^3.0.3
|
||||
adaptive_page_layout: ^0.1.6
|
||||
provider: ^4.3.2+4
|
||||
|
Loading…
x
Reference in New Issue
Block a user