mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 07:35:13 +00:00
feat: Switch to firebase messaging package
This commit is contained in:
parent
aefc808125
commit
757b0e2274
23 changed files with 128 additions and 253 deletions
2
.github/workflows/integrate.yaml
vendored
2
.github/workflows/integrate.yaml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
|||
run: dart run license_checker check-licenses -c licenses.yaml --problematic
|
||||
- run: flutter analyze
|
||||
- name: Apply google services patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
run: ./scripts/enable-google-services.sh
|
||||
- run: flutter analyze
|
||||
- run: flutter test
|
||||
|
||||
|
|
2
.github/workflows/main_deploy.yaml
vendored
2
.github/workflows/main_deploy.yaml
vendored
|
@ -57,7 +57,7 @@ jobs:
|
|||
- name: Install Fastlane
|
||||
run: gem install fastlane -NV
|
||||
- name: Apply Google Services Patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
run: ./scripts/enable-google-services.sh
|
||||
- name: Remove Emoji Font
|
||||
run: |
|
||||
rm -rf fonts/NotoEmoji
|
||||
|
|
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
|
@ -80,7 +80,7 @@ jobs:
|
|||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||
cache: true
|
||||
- name: Apply Google Services Patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
run: ./scripts/enable-google-services.sh
|
||||
- name: Remove Emoji Font
|
||||
run: |
|
||||
rm -rf fonts/NotoEmoji
|
||||
|
@ -148,7 +148,7 @@ jobs:
|
|||
- name: Install Fastlane
|
||||
run: gem install fastlane -NV
|
||||
- name: Apply Google Services Patch
|
||||
run: git apply ./scripts/enable-android-google-services.patch
|
||||
run: ./scripts/enable-google-services.sh
|
||||
- name: Remove Emoji Font
|
||||
run: |
|
||||
rm -rf fonts/NotoEmoji
|
||||
|
|
|
@ -86,8 +86,7 @@ flutter {
|
|||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
//implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
}
|
||||
|
||||
//apply plugin: 'com.google.gms.google-services'
|
||||
//<GOOGLE_SERVICES>apply plugin: 'com.google.gms.google-services'
|
||||
|
|
|
@ -113,13 +113,6 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name=".FcmPushService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
|
||||
android:foregroundServiceType="camera|microphone|mediaProjection">
|
||||
</service>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*package chat.fluffy.fluffychat
|
||||
|
||||
import com.famedly.fcm_shared_isolate.FcmSharedIsolateService
|
||||
|
||||
import chat.fluffy.fluffychat.MainActivity
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.view.FlutterMain
|
||||
import io.flutter.embedding.engine.dart.DartExecutor.DartEntrypoint
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.WindowManager
|
||||
|
||||
class FcmPushService : FcmSharedIsolateService() {
|
||||
override fun getEngine(): FlutterEngine {
|
||||
return provideEngine(getApplicationContext())
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun provideEngine(context: Context): FlutterEngine {
|
||||
var engine = MainActivity.engine
|
||||
if (engine == null) {
|
||||
engine = MainActivity.provideEngine(context)
|
||||
engine.getLocalizationPlugin().sendLocalesToFlutter(
|
||||
context.getResources().getConfiguration())
|
||||
engine.getDartExecutor().executeDartEntrypoint(
|
||||
DartEntrypoint.createDefault())
|
||||
}
|
||||
return engine
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -7,13 +7,11 @@ import android.content.Context
|
|||
import androidx.multidex.MultiDex
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
|
||||
override fun attachBaseContext(base: Context) {
|
||||
super.attachBaseContext(base)
|
||||
MultiDex.install(this)
|
||||
}
|
||||
|
||||
|
||||
override fun provideFlutterEngine(context: Context): FlutterEngine? {
|
||||
return provideEngine(this)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
//classpath 'com.google.gms:google-services:4.3.8'
|
||||
//<GOOGLE_SERVICES>classpath 'com.google.gms:google-services:4.3.8'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
firebase.json
Normal file
1
firebase.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"flutter":{"platforms":{"android":{"default":{"projectId":"fluffychat-ef3e8","appId":"1:865731724731:android:ec427b3b1dcd4a1e64309e","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"fluffychat-ef3e8","appId":"1:865731724731:ios:79fd983ce46cb40c64309e","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"macos":{"default":{"projectId":"fluffychat-ef3e8","appId":"1:865731724731:ios:6fb777cf513cdb6264309e","uploadDebugSymbols":false,"fileOutput":"macos/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"fluffychat-ef3e8","configurations":{"android":"1:865731724731:android:ec427b3b1dcd4a1e64309e","ios":"1:865731724731:ios:79fd983ce46cb40c64309e","macos":"1:865731724731:ios:6fb777cf513cdb6264309e","web":"1:865731724731:web:d367990bc625c24864309e"}}}}}}
|
|
@ -1,3 +1,5 @@
|
|||
//<GOOGLE_SERVICES>import 'package:firebase_core/firebase_core.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
@ -21,6 +23,8 @@ void main() async {
|
|||
// widget bindings are initialized already.
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
//<GOOGLE_SERVICES>await Firebase.initializeApp();
|
||||
|
||||
Logs().nativeColors = !PlatformInfos.isIOS;
|
||||
final store = await SharedPreferences.getInstance();
|
||||
final clients = await ClientManager.getClients(store: store);
|
||||
|
|
|
@ -38,7 +38,7 @@ import '../config/setting_keys.dart';
|
|||
import '../widgets/matrix.dart';
|
||||
import 'platform_infos.dart';
|
||||
|
||||
//import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
|
||||
//<GOOGLE_SERVICES>import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
class NoTokenException implements Exception {
|
||||
String get cause => 'Cannot get firebase token';
|
||||
|
@ -63,24 +63,23 @@ class BackgroundPush {
|
|||
|
||||
final pendingTests = <String, Completer<void>>{};
|
||||
|
||||
final dynamic firebase = null; //FcmSharedIsolate();
|
||||
//<GOOGLE_SERVICES>final firebase = FirebaseMessaging.instance;
|
||||
|
||||
DateTime? lastReceivedPush;
|
||||
|
||||
bool upAction = false;
|
||||
|
||||
BackgroundPush._(this.client) {
|
||||
firebase?.setListeners(
|
||||
onMessage: (message) => pushHelper(
|
||||
PushNotification.fromJson(
|
||||
Map<String, dynamic>.from(message['data'] ?? message),
|
||||
),
|
||||
void onMessage(message) => pushHelper(
|
||||
PushNotification.fromJson(Map<String, dynamic>.from(message.data)),
|
||||
client: client,
|
||||
l10n: l10n,
|
||||
activeRoomId: matrix?.activeRoomId,
|
||||
onSelectNotification: goToRoom,
|
||||
),
|
||||
);
|
||||
|
||||
BackgroundPush._(this.client) {
|
||||
//<GOOGLE_SERVICES>FirebaseMessaging.onMessage.listen(onMessage);
|
||||
//<GOOGLE_SERVICES>FirebaseMessaging.onBackgroundMessage(pushHelperBackground);
|
||||
if (Platform.isAndroid) {
|
||||
UnifiedPush.initialize(
|
||||
onNewEndpoint: _newUpEndpoint,
|
||||
|
@ -132,7 +131,7 @@ class BackgroundPush {
|
|||
bool useDeviceSpecificAppId = false,
|
||||
}) async {
|
||||
if (PlatformInfos.isIOS) {
|
||||
await firebase?.requestPermission();
|
||||
//<GOOGLE_SERVICES> await firebase.requestPermission();
|
||||
} else if (PlatformInfos.isAndroid) {
|
||||
_flutterLocalNotificationsPlugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
|
@ -289,7 +288,7 @@ class BackgroundPush {
|
|||
Logs().v('Setup firebase');
|
||||
if (_fcmToken?.isEmpty ?? true) {
|
||||
try {
|
||||
_fcmToken = await firebase?.getToken();
|
||||
//<GOOGLE_SERVICES>_fcmToken = await firebase.getToken();
|
||||
if (_fcmToken == null) throw ('PushToken is null');
|
||||
} catch (e, s) {
|
||||
Logs().w('[Push] cannot get token', e, e is String ? null : s);
|
||||
|
@ -358,7 +357,8 @@ class BackgroundPush {
|
|||
Logs().i('[Push] UnifiedPush using endpoint $endpoint');
|
||||
final oldTokens = <String?>{};
|
||||
try {
|
||||
final fcmToken = await firebase?.getToken();
|
||||
String? fcmToken;
|
||||
//<GOOGLE_SERVICES>fcmToken = await firebase.getToken();
|
||||
oldTokens.add(fcmToken);
|
||||
} catch (_) {}
|
||||
await setupPusher(
|
||||
|
|
|
@ -23,7 +23,7 @@ import 'matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart';
|
|||
abstract class ClientManager {
|
||||
static const String clientNamespace = 'im.fluffychat.store.clients';
|
||||
static Future<List<Client>> getClients({
|
||||
bool initialize = true,
|
||||
bool isBackgroundClient = false,
|
||||
required SharedPreferences store,
|
||||
}) async {
|
||||
if (PlatformInfos.isLinux) {
|
||||
|
@ -44,10 +44,12 @@ abstract class ClientManager {
|
|||
await store.setStringList(clientNamespace, clientNames.toList());
|
||||
}
|
||||
final clients = clientNames.map(createClient).toList();
|
||||
if (initialize) {
|
||||
|
||||
await Future.wait(
|
||||
clients.map(
|
||||
(client) => client.initWithRestore(
|
||||
(client) => client
|
||||
.initWithRestore(
|
||||
isBackgroundClient: isBackgroundClient,
|
||||
onMigration: () {
|
||||
final l10n = lookupL10n(PlatformDispatcher.instance.locale);
|
||||
sendInitNotification(
|
||||
|
@ -55,12 +57,13 @@ abstract class ClientManager {
|
|||
l10n.databaseMigrationBody,
|
||||
);
|
||||
},
|
||||
).catchError(
|
||||
)
|
||||
.catchError(
|
||||
(e, s) => Logs().e('Unable to initialize client', e, s),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (clients.length > 1 && clients.any((c) => !c.isLogged())) {
|
||||
final loggedOutClients = clients.where((c) => !c.isLogged()).toList();
|
||||
for (final client in loggedOutClients) {
|
||||
|
|
|
@ -61,7 +61,10 @@ extension InitWithRestoreExtension on Client {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> initWithRestore({void Function()? onMigration}) async {
|
||||
Future<void> initWithRestore({
|
||||
bool isBackgroundClient = false,
|
||||
void Function()? onMigration,
|
||||
}) async {
|
||||
final storageKey =
|
||||
'${AppConfig.applicationName}_session_backup_$clientName';
|
||||
final storage = PlatformInfos.isMobile || PlatformInfos.isLinux
|
||||
|
@ -69,6 +72,7 @@ extension InitWithRestoreExtension on Client {
|
|||
: null;
|
||||
|
||||
try {
|
||||
if (isBackgroundClient) await abortSync();
|
||||
await init(
|
||||
onMigration: onMigration,
|
||||
waitForFirstSync: false,
|
||||
|
|
|
@ -18,6 +18,10 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/voip/callkeep_manager.dart';
|
||||
|
||||
Future<void> pushHelperBackground(message) => pushHelper(
|
||||
PushNotification.fromJson(message.data),
|
||||
);
|
||||
|
||||
Future<void> pushHelper(
|
||||
PushNotification notification, {
|
||||
Client? client,
|
||||
|
@ -53,7 +57,7 @@ Future<void> pushHelper(
|
|||
l10n.newMessageInFluffyChat,
|
||||
l10n.openAppToReadMessages,
|
||||
NotificationDetails(
|
||||
iOS: const DarwinNotificationDetails(),
|
||||
iOS: const DarwinNotificationDetails(sound: 'notification.caf'),
|
||||
android: AndroidNotificationDetails(
|
||||
AppConfig.pushNotificationsChannelId,
|
||||
l10n.incomingMessages,
|
||||
|
@ -104,7 +108,7 @@ Future<void> _tryPushHelper(
|
|||
);
|
||||
|
||||
client ??= (await ClientManager.getClients(
|
||||
initialize: false,
|
||||
isBackgroundClient: true,
|
||||
store: await SharedPreferences.getInstance(),
|
||||
))
|
||||
.first;
|
||||
|
@ -292,7 +296,9 @@ Future<void> _tryPushHelper(
|
|||
priority: Priority.max,
|
||||
groupKey: notificationGroupId,
|
||||
);
|
||||
const iOSPlatformChannelSpecifics = DarwinNotificationDetails();
|
||||
const iOSPlatformChannelSpecifics = DarwinNotificationDetails(
|
||||
sound: "notification.caf",
|
||||
);
|
||||
final platformChannelSpecifics = NotificationDetails(
|
||||
android: androidPlatformChannelSpecifics,
|
||||
iOS: iOSPlatformChannelSpecifics,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
|
||||
3AF44CC3D61A8332019AFCDE /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5AEFA815523969D4ADFBE7E8 /* GoogleService-Info.plist */; };
|
||||
9CAF203E1D098383F2EDFFCB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3C62FEBAA272B5A33AFFC95 /* Pods_Runner.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -69,6 +70,7 @@
|
|||
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
|
||||
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
|
||||
35E6B919318905352ECC7D69 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
5AEFA815523969D4ADFBE7E8 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||
5CDC3DD55F4AC23D2067B292 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
|
@ -110,6 +112,7 @@
|
|||
33CC10EE2044A3C60003C045 /* Products */,
|
||||
D73912EC22F37F3D000D13A0 /* Frameworks */,
|
||||
F9F203356080D460FB6D4567 /* Pods */,
|
||||
5AEFA815523969D4ADFBE7E8 /* GoogleService-Info.plist */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
@ -255,6 +258,7 @@
|
|||
files = (
|
||||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
|
||||
3AF44CC3D61A8332019AFCDE /* GoogleService-Info.plist in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
30
macos/Runner/GoogleService-Info.plist
Normal file
30
macos/Runner/GoogleService-Info.plist
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyA8ZUBcuny0HjPwF2Q2fvDyQTC5dG2VHlE</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>865731724731</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>im.fluffychat.fluffychat</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>fluffychat-ef3e8</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>fluffychat-ef3e8.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:865731724731:ios:6fb777cf513cdb6264309e</string>
|
||||
</dict>
|
||||
</plist>
|
17
pubspec.lock
17
pubspec.lock
|
@ -2307,6 +2307,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.1"
|
||||
wakelock_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: wakelock_platform_interface
|
||||
sha256: "1f4aeb81fb592b863da83d2d0f7b8196067451e4df91046c26b54a403f9de621"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
wakelock_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -2323,6 +2331,15 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
wakelock_windows:
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
path: wakelock_windows
|
||||
ref: main
|
||||
resolved-ref: f3610d6c246098fee74463de09434ed81fc2a7c8
|
||||
url: "https://github.com/chandrabezzo/wakelock.git"
|
||||
source: git
|
||||
version: "0.2.2"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -25,8 +25,9 @@ dependencies:
|
|||
emoji_picker_flutter: ^2.1.1
|
||||
emoji_proposal: ^0.0.1
|
||||
emojis: ^0.9.9
|
||||
#fcm_shared_isolate: ^0.1.0
|
||||
file_picker: ^8.0.1
|
||||
#<GOOGLE_SERVICES>firebase_core: ^2.24.2
|
||||
#<GOOGLE_SERVICES>firebase_messaging: ^14.7.9
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_app_badger: ^1.5.0
|
||||
|
@ -160,3 +161,9 @@ dependency_overrides:
|
|||
git:
|
||||
url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git
|
||||
ref: null-safety
|
||||
# blocked upgrade of package_info_plus for null safety
|
||||
wakelock_windows:
|
||||
git:
|
||||
url: https://github.com/chandrabezzo/wakelock.git
|
||||
ref: main
|
||||
path: wakelock_windows/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
git apply ./scripts/enable-android-google-services.patch
|
||||
./scripts/enable-google-services.sh
|
||||
FLUFFYCHAT_ORIG_GROUP="im.fluffychat"
|
||||
FLUFFYCHAT_ORIG_TEAM="4NXF6Z997G"
|
||||
#FLUFFYCHAT_NEW_GROUP="com.example.fluffychat"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
git apply ./scripts/enable-android-google-services.patch
|
||||
./scripts/enable-google-services.sh
|
||||
FLUFFYCHAT_ORIG_GROUP="im.fluffychat"
|
||||
FLUFFYCHAT_ORIG_TEAM="4NXF6Z997G"
|
||||
#FLUFFYCHAT_NEW_GROUP="com.example.fluffychat"
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
diff --git a/android/app/build.gradle b/android/app/build.gradle
|
||||
index bf972f30..46cebdc6 100644
|
||||
--- a/android/app/build.gradle
|
||||
+++ b/android/app/build.gradle
|
||||
@@ -70,6 +70,10 @@
|
||||
}
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
+ minifyEnabled false
|
||||
+ shrinkResources false
|
||||
+
|
||||
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
// https://stackoverflow.com/a/77494454/8222484
|
||||
@@ -78,8 +82,11 @@ flutter {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
- //implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698
|
||||
+ implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698
|
||||
+ testImplementation 'junit:junit:4.12'
|
||||
+ androidTestImplementation 'androidx.test:runner:1.1.1'
|
||||
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
}
|
||||
|
||||
-//apply plugin: 'com.google.gms.google-services'
|
||||
+apply plugin: 'com.google.gms.google-services'
|
||||
diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro
|
||||
index d0e0fbc9..0a546da0 100644
|
||||
--- a/android/app/proguard-rules.pro
|
||||
+++ b/android/app/proguard-rules.pro
|
||||
@@ -1 +1,42 @@
|
||||
--keep class net.sqlcipher.** { *; }
|
||||
\ No newline at end of file
|
||||
+-optimizationpasses 5
|
||||
+## Flutter wrapper
|
||||
+-keep class net.sqlcipher.** { *; }
|
||||
+-keep class io.flutter.app.** { *; }
|
||||
+-keep class io.flutter.plugin.** { *; }
|
||||
+-keep class io.flutter.util.** { *; }
|
||||
+-keep class io.flutter.view.** { *; }
|
||||
+-keep class io.flutter.** { *; }
|
||||
+-keep class io.flutter.plugins.** { *; }
|
||||
+-dontwarn io.flutter.embedding.**
|
||||
+
|
||||
+##---------------Begin: proguard configuration for Gson (Needed for flutter_local_notifications) ----------
|
||||
+# Gson uses generic type information stored in a class file when working with fields. Proguard
|
||||
+# removes such information by default, so configure it to keep all of it.
|
||||
+-keepattributes Signature
|
||||
+
|
||||
+# For using GSON @Expose annotation
|
||||
+-keepattributes *Annotation*
|
||||
+
|
||||
+# Gson specific classes
|
||||
+-dontwarn sun.misc.**
|
||||
+
|
||||
+# Application classes that will be serialized/deserialized over Gson
|
||||
+-keep class com.google.gson.examples.android.model.** { <fields>; }
|
||||
+
|
||||
+# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
|
||||
+# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
+-keep class * extends com.google.gson.TypeAdapter
|
||||
+-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
+-keep class * implements com.google.gson.JsonSerializer
|
||||
+-keep class * implements com.google.gson.JsonDeserializer
|
||||
+
|
||||
+# Prevent R8 from leaving Data object members always null
|
||||
+-keepclassmembers,allowobfuscation class * {
|
||||
+ @com.google.gson.annotations.SerializedName <fields>;
|
||||
+}
|
||||
+
|
||||
+# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
|
||||
+-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
||||
+-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
||||
+
|
||||
+##---------------End: proguard configuration for Gson (Needed for flutter_local_notifications) ----------
|
||||
\ No newline at end of file
|
||||
diff --git a/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt b/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt
|
||||
index d9930f55..510e9845 100644
|
||||
--- a/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt
|
||||
+++ b/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt
|
||||
@@ -1,4 +1,4 @@
|
||||
-/*package chat.fluffy.fluffychat
|
||||
+package chat.fluffy.fluffychat
|
||||
|
||||
import com.famedly.fcm_shared_isolate.FcmSharedIsolateService
|
||||
|
||||
@@ -33,4 +33,3 @@ class FcmPushService : FcmSharedIsolateService() {
|
||||
}
|
||||
}
|
||||
}
|
||||
-*/
|
||||
\ No newline at end of file
|
||||
diff --git a/android/app/src/main/kotlin/chat/fluffy/fluffychat/MainActivity.kt b/android/app/src/main/kotlin/chat/fluffy/fluffychat/MainActivity.kt
|
||||
index 1afc4606..894d1571 100644
|
||||
--- a/android/app/src/main/kotlin/chat/fluffy/fluffychat/MainActivity.kt
|
||||
+++ b/android/app/src/main/kotlin/chat/fluffy/fluffychat/MainActivity.kt
|
||||
@@ -7,13 +7,11 @@ import android.content.Context
|
||||
import androidx.multidex.MultiDex
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
-
|
||||
override fun attachBaseContext(base: Context) {
|
||||
super.attachBaseContext(base)
|
||||
MultiDex.install(this)
|
||||
}
|
||||
|
||||
-
|
||||
override fun provideFlutterEngine(context: Context): FlutterEngine? {
|
||||
return provideEngine(this)
|
||||
}
|
||||
diff --git a/android/build.gradle b/android/build.gradle
|
||||
index bd394967..2e9d54de 100644
|
||||
--- a/android/build.gradle
|
||||
+++ b/android/build.gradle
|
||||
@@ -8,7 +8,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
- //classpath 'com.google.gms:google-services:4.3.8'
|
||||
+ classpath 'com.google.gms:google-services:4.3.8'
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart
|
||||
index 8e67ae92..da4da5c3 100644
|
||||
--- a/lib/utils/background_push.dart
|
||||
+++ b/lib/utils/background_push.dart
|
||||
@@ -39,7 +39,7 @@ import '../config/setting_keys.dart';
|
||||
import '../widgets/matrix.dart';
|
||||
import 'platform_infos.dart';
|
||||
|
||||
-//import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
|
||||
+import 'package:fcm_shared_isolate/fcm_shared_isolate.dart';
|
||||
|
||||
class NoTokenException implements Exception {
|
||||
String get cause => 'Cannot get firebase token';
|
||||
@@ -64,7 +64,7 @@ class BackgroundPush {
|
||||
|
||||
final pendingTests = <String, Completer<void>>{};
|
||||
|
||||
- final dynamic firebase = null; //FcmSharedIsolate();
|
||||
+ final dynamic firebase = FcmSharedIsolate();
|
||||
|
||||
DateTime? lastReceivedPush;
|
||||
|
||||
diff --git a/pubspec.yaml b/pubspec.yaml
|
||||
index 193e6ed6..f70e48d4 100644
|
||||
--- a/pubspec.yaml
|
||||
+++ b/pubspec.yaml
|
||||
@@ -26,7 +26,7 @@ dependencies:
|
||||
emoji_picker_flutter: ^2.1.1
|
||||
emoji_proposal: ^0.0.1
|
||||
emojis: ^0.9.9
|
||||
- #fcm_shared_isolate: ^0.1.0
|
||||
+ fcm_shared_isolate: ^0.1.0
|
||||
file_picker: ^8.0.1
|
||||
flutter:
|
||||
sdk: flutter
|
6
scripts/enable-google-services.sh
Executable file
6
scripts/enable-google-services.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
sed -i 's/#<GOOGLE_SERVICES>//g' pubspec.yaml
|
||||
sed -i 's,//<GOOGLE_SERVICES>,,g' android/build.gradle
|
||||
sed -i 's,//<GOOGLE_SERVICES>,,g' android/app/build.gradle
|
||||
sed -i 's,//<GOOGLE_SERVICES>,,g' lib/main.dart
|
||||
sed -i 's,//<GOOGLE_SERVICES>,,g' lib/utils/background_push.dart
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh -ve
|
||||
git apply ./scripts/enable-android-google-services.patch
|
||||
./scripts/enable-google-services.sh
|
||||
rm -rf fonts/NotoEmoji
|
||||
yq -i 'del( .flutter.fonts[] | select(.family == "NotoEmoji") )' pubspec.yaml
|
||||
flutter clean
|
||||
|
|
Loading…
Reference in a new issue