Skip to content

Commit

Permalink
[FEATURE] 通知タップ時の挙動を追加 (#702)
Browse files Browse the repository at this point in the history
* add
  • Loading branch information
YumNumm authored May 30, 2024
1 parent 15be289 commit a553519
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 17 deletions.
16 changes: 0 additions & 16 deletions app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -242,7 +230,6 @@
85E6094A2BFF792C00C21983 /* Sources */,
85E6094B2BFF792C00C21983 /* Frameworks */,
85E6094C2BFF792C00C21983 /* Resources */,
85B405152C08E0DA00EB3835 /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
18 changes: 18 additions & 0 deletions app/lib/core/provider/firebase/firebase_messaging_interaction.dart
Original file line number Diff line number Diff line change
@@ -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<RemoteMessage> firebaseMessagingInteraction(
FirebaseMessagingInteractionRef ref,
) async* {
final messaging = ref.watch(firebaseMessagingProvider);
final initialMessage = await messaging.getInitialMessage();
if (initialMessage != null) {
yield initialMessage;
}

yield* FirebaseMessaging.onMessageOpenedApp;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions app/lib/feature/home/view/home_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';

import 'package:collection/collection.dart';
Expand All @@ -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';
Expand All @@ -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});
Expand Down Expand Up @@ -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(),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a553519

Please sign in to comment.