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