diff --git a/app/ios/Runner.xcodeproj/project.pbxproj b/app/ios/Runner.xcodeproj/project.pbxproj index 4ee4e5db4..eee8dce18 100644 --- a/app/ios/Runner.xcodeproj/project.pbxproj +++ b/app/ios/Runner.xcodeproj/project.pbxproj @@ -17,7 +17,6 @@ 859DF75C2BBE9FFC00B827B1 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 859DF75B2BBE9FFC00B827B1 /* StoreKit.framework */; }; 859DF75E2BBEA0F000B827B1 /* Synced - EQMonitor.storekit in Resources */ = {isa = PBXBuildFile; fileRef = 859DF75D2BBEA0F000B827B1 /* Synced - EQMonitor.storekit */; }; 85B405132C08E0DA00EB3835 /* Pods_FcmServiceExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B391858A4EFC95F561B05E /* Pods_FcmServiceExtension.framework */; }; - 85B405142C08E0DA00EB3835 /* Pods_FcmServiceExtension.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 99B391858A4EFC95F561B05E /* Pods_FcmServiceExtension.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 85B4051A2C08E73300EB3835 /* Gzip in Frameworks */ = {isa = PBXBuildFile; productRef = 85B405192C08E73300EB3835 /* Gzip */; }; 85E609552BFF792C00C21983 /* FcmServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 85E6094E2BFF792C00C21983 /* FcmServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 85E6095B2BFF7AC300C21983 /* notification_payload.proto in Sources */ = {isa = PBXBuildFile; fileRef = 85E6095A2BFF7AC300C21983 /* notification_payload.proto */; }; @@ -51,17 +50,6 @@ name = "Embed Foundation Extensions"; runOnlyForDeploymentPostprocessing = 0; }; - 85B405152C08E0DA00EB3835 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 85B405142C08E0DA00EB3835 /* Pods_FcmServiceExtension.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; 9705A1C41CF9048500538489 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -242,7 +230,6 @@ 85E6094A2BFF792C00C21983 /* Sources */, 85E6094B2BFF792C00C21983 /* Frameworks */, 85E6094C2BFF792C00C21983 /* Resources */, - 85B405152C08E0DA00EB3835 /* Embed Frameworks */, ); buildRules = ( ); @@ -625,7 +612,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = BAD419430E9ED3DD1D1D656D /* Pods-FcmServiceExtension.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -673,7 +659,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = BB2485496F3FDA0206409B97 /* Pods-FcmServiceExtension.release.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; @@ -718,7 +703,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = A44F22D7804610848A5A41DF /* Pods-FcmServiceExtension.profile.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; diff --git a/app/lib/core/provider/firebase/firebase_messaging_interaction.dart b/app/lib/core/provider/firebase/firebase_messaging_interaction.dart new file mode 100644 index 000000000..14f94313e --- /dev/null +++ b/app/lib/core/provider/firebase/firebase_messaging_interaction.dart @@ -0,0 +1,18 @@ +import 'package:eqmonitor/core/provider/firebase/firebase_messaging.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'firebase_messaging_interaction.g.dart'; + +@Riverpod(keepAlive: true) +Stream firebaseMessagingInteraction( + FirebaseMessagingInteractionRef ref, +) async* { + final messaging = ref.watch(firebaseMessagingProvider); + final initialMessage = await messaging.getInitialMessage(); + if (initialMessage != null) { + yield initialMessage; + } + + yield* FirebaseMessaging.onMessageOpenedApp; +} diff --git a/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart b/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart new file mode 100644 index 000000000..b8cc3d80f --- /dev/null +++ b/app/lib/core/provider/firebase/firebase_messaging_interaction.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: type=lint, duplicate_ignore + +part of 'firebase_messaging_interaction.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$firebaseMessagingInteractionHash() => + r'991b7b483ec1c1c934d9ae2e67b093ba48746cf1'; + +/// See also [firebaseMessagingInteraction]. +@ProviderFor(firebaseMessagingInteraction) +final firebaseMessagingInteractionProvider = + StreamProvider.internal( + firebaseMessagingInteraction, + name: r'firebaseMessagingInteractionProvider', + debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') + ? null + : _$firebaseMessagingInteractionHash, + dependencies: null, + allTransitiveDependencies: null, +); + +typedef FirebaseMessagingInteractionRef = StreamProviderRef; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, inference_failure_on_uninitialized_variable, inference_failure_on_function_return_type, inference_failure_on_untyped_parameter, deprecated_member_use_from_same_package diff --git a/app/lib/feature/home/view/home_view.dart b/app/lib/feature/home/view/home_view.dart index 6bb7eafb2..3e9ca3f0b 100644 --- a/app/lib/feature/home/view/home_view.dart +++ b/app/lib/feature/home/view/home_view.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'dart:math'; import 'package:collection/collection.dart'; @@ -13,9 +14,11 @@ import 'package:eqmonitor/core/hook/use_sheet_controller.dart'; import 'package:eqmonitor/core/provider/capture/intensity_icon_render.dart'; import 'package:eqmonitor/core/provider/config/permission/permission_status_provider.dart'; import 'package:eqmonitor/core/provider/eew/eew_alive_telegram.dart'; +import 'package:eqmonitor/core/provider/firebase/firebase_messaging_interaction.dart'; import 'package:eqmonitor/core/provider/kmoni/viewmodel/kmoni_settings.dart'; import 'package:eqmonitor/core/provider/kmoni/viewmodel/kmoni_view_model.dart'; import 'package:eqmonitor/core/provider/kmoni/widget/kmoni_maintenance_widget.dart'; +import 'package:eqmonitor/core/provider/log/talker.dart'; import 'package:eqmonitor/core/provider/notification_token.dart'; import 'package:eqmonitor/core/provider/ntp/ntp_provider.dart'; import 'package:eqmonitor/core/router/router.dart'; @@ -37,6 +40,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:sheet/sheet.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class HomeView extends HookConsumerWidget { const HomeView({super.key}); @@ -212,6 +216,32 @@ class _HomeBodyWidget extends HookConsumerWidget { [], ); + ref.listen( + firebaseMessagingInteractionProvider, + (_, next) async { + if (next case AsyncData(:final value)) { + ref.read(talkerProvider).log( + 'Handle Firebase Message: ' + "${const JsonEncoder.withIndent(' ').convert(value.toMap())}", + ); + + final route = value.data['route']; + if (route is String) { + ref.read(goRouterProvider).go(route); + return; + } + final url = value.data['url']; + if (url is String) { + final canLaunch = await canLaunchUrlString(url); + if (canLaunch) { + await launchUrlString(url); + } + return; + } + } + }, + ); + final child = Stack( children: [ const MainMapView(), diff --git a/app/lib/feature/settings/features/notification_remote_settings/data/service/notification_remote_settings_migrate_service.g.dart b/app/lib/feature/settings/features/notification_remote_settings/data/service/notification_remote_settings_migrate_service.g.dart index 9c9cb0d5e..2e33166a5 100644 --- a/app/lib/feature/settings/features/notification_remote_settings/data/service/notification_remote_settings_migrate_service.g.dart +++ b/app/lib/feature/settings/features/notification_remote_settings/data/service/notification_remote_settings_migrate_service.g.dart @@ -9,7 +9,7 @@ part of 'notification_remote_settings_migrate_service.dart'; // ************************************************************************** String _$notificationRemoteSettingsInitialSetupNotifierHash() => - r'82aadd31b14fcff9336cca9e289aa399dbd32bff'; + r'02782eb79aca9e4c1c2beeb9e6350bd433554b3b'; /// See also [NotificationRemoteSettingsInitialSetupNotifier]. @ProviderFor(NotificationRemoteSettingsInitialSetupNotifier)