Skip to content

Commit f8f7c95

Browse files
authored
Request permission only if not requested before (#1171)
1 parent 5320f07 commit f8f7c95

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

app/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,10 @@
219219
inputFileListPaths = (
220220
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
221221
);
222-
inputPaths = (
223-
);
224222
name = "[CP] Embed Pods Frameworks";
225223
outputFileListPaths = (
226224
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
227225
);
228-
outputPaths = (
229-
);
230226
runOnlyForDeploymentPostprocessing = 0;
231227
shellPath = /bin/sh;
232228
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";

app/lib/services/notification_service.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
55
import 'package:threebotlogin/helpers/logger.dart';
66
import 'package:threebotlogin/main.dart';
77
import 'package:threebotlogin/widgets/custom_dialog.dart';
8+
import 'package:shared_preferences/shared_preferences.dart';
89

910
@pragma('vm:entry-point')
1011
Future<void> onActionReceivedMethod(ReceivedAction receivedAction) async {
@@ -59,11 +60,15 @@ class NotificationService {
5960
onDismissActionReceivedMethod: _onDismissActionReceived,
6061
);
6162

62-
await AwesomeNotifications().isNotificationAllowed().then((isAllowed) {
63-
if (!isAllowed) {
64-
AwesomeNotifications().requestPermissionToSendNotifications();
63+
final isAllowed = await AwesomeNotifications().isNotificationAllowed();
64+
if (!isAllowed) {
65+
final prefs = await SharedPreferences.getInstance();
66+
final hasRequestedBefore = prefs.getBool('notification_permission_requested') ?? false;
67+
if (!hasRequestedBefore) {
68+
await AwesomeNotifications().requestPermissionToSendNotifications();
69+
await prefs.setBool('notification_permission_requested', true);
6570
}
66-
});
71+
}
6772

6873
_isInitialized = true;
6974
}

app/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import app_links
89
import audio_session
910
import awesome_notifications
1011
import connectivity_plus
1112
import device_info_plus
1213
import flutter_inappwebview_macos
1314
import just_audio
15+
import local_auth_darwin
1416
import mobile_scanner
1517
import open_file_mac
1618
import package_info_plus
@@ -25,12 +27,14 @@ import wakelock_plus
2527
import webview_flutter_wkwebview
2628

2729
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
30+
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
2831
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
2932
AwesomeNotificationsPlugin.register(with: registry.registrar(forPlugin: "AwesomeNotificationsPlugin"))
3033
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
3134
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
3235
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
3336
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
37+
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
3438
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
3539
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
3640
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))

0 commit comments

Comments
 (0)