Skip to content

Commit 525d863

Browse files
authored
fix: notification permission (#71)
1 parent b47ed16 commit 525d863

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ post_install do |installer|
7878
##'PERMISSION_LOCATION_WHENINUSE=0',
7979

8080
## dart: PermissionGroup.notification
81-
##'PERMISSION_NOTIFICATIONS=1',
81+
'PERMISSION_NOTIFICATIONS=1',
8282

8383
## dart: PermissionGroup.mediaLibrary
8484
##'PERMISSION_MEDIA_LIBRARY=1',

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,12 @@
378378
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
379379
CLANG_ENABLE_MODULES = YES;
380380
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
381+
CODE_SIGN_IDENTITY = "Apple Development";
382+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
383+
CODE_SIGN_STYLE = Manual;
381384
CURRENT_PROJECT_VERSION = 74;
382-
DEVELOPMENT_TEAM = 3PFDRPLY6N;
385+
DEVELOPMENT_TEAM = "";
386+
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 3PFDRPLY6N;
383387
ENABLE_BITCODE = NO;
384388
INFOPLIST_FILE = Runner/Info.plist;
385389
INFOPLIST_KEY_CFBundleDisplayName = MY.SOLVED;
@@ -390,6 +394,8 @@
390394
MARKETING_VERSION = 2.0.5;
391395
PRODUCT_BUNDLE_IDENTIFIER = com.jeehoukjung.mySolved;
392396
PRODUCT_NAME = "$(TARGET_NAME)";
397+
PROVISIONING_PROFILE_SPECIFIER = "";
398+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "My.solved distribution";
393399
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
394400
SUPPORTS_MACCATALYST = NO;
395401
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
@@ -514,8 +520,12 @@
514520
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
515521
CLANG_ENABLE_MODULES = YES;
516522
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
523+
CODE_SIGN_IDENTITY = "Apple Development";
524+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
525+
CODE_SIGN_STYLE = Manual;
517526
CURRENT_PROJECT_VERSION = 74;
518-
DEVELOPMENT_TEAM = 3PFDRPLY6N;
527+
DEVELOPMENT_TEAM = "";
528+
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 3PFDRPLY6N;
519529
ENABLE_BITCODE = NO;
520530
INFOPLIST_FILE = Runner/Info.plist;
521531
INFOPLIST_KEY_CFBundleDisplayName = MY.SOLVED;
@@ -526,6 +536,8 @@
526536
MARKETING_VERSION = 2.0.5;
527537
PRODUCT_BUNDLE_IDENTIFIER = com.jeehoukjung.mySolved;
528538
PRODUCT_NAME = "$(TARGET_NAME)";
539+
PROVISIONING_PROFILE_SPECIFIER = "";
540+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "My.solved distribution";
529541
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
530542
SUPPORTS_MACCATALYST = NO;
531543
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
@@ -544,8 +556,12 @@
544556
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
545557
CLANG_ENABLE_MODULES = YES;
546558
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
559+
CODE_SIGN_IDENTITY = "Apple Development";
560+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
561+
CODE_SIGN_STYLE = Manual;
547562
CURRENT_PROJECT_VERSION = 74;
548-
DEVELOPMENT_TEAM = 3PFDRPLY6N;
563+
DEVELOPMENT_TEAM = "";
564+
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 3PFDRPLY6N;
549565
ENABLE_BITCODE = NO;
550566
INFOPLIST_FILE = Runner/Info.plist;
551567
INFOPLIST_KEY_CFBundleDisplayName = MY.SOLVED;
@@ -556,6 +572,8 @@
556572
MARKETING_VERSION = 2.0.5;
557573
PRODUCT_BUNDLE_IDENTIFIER = com.jeehoukjung.mySolved;
558574
PRODUCT_NAME = "$(TARGET_NAME)";
575+
PROVISIONING_PROFILE_SPECIFIER = "";
576+
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "My.solved distribution";
559577
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
560578
SUPPORTS_MACCATALYST = NO;
561579
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;

lib/features/contest/bloc/contest_bloc.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,18 @@ class ContestBloc extends Bloc<ContestEvent, ContestState> {
7878
ContestNotificationButtonPressed event,
7979
Emitter<ContestState> emit,
8080
) async {
81-
var status = await Permission.notification.status;
82-
if (status.isDenied) {
83-
status = await Permission.notification.request();
84-
} else if (status.isPermanentlyDenied) {
85-
await openAppSettings();
86-
status = await Permission.notification.status;
87-
}
81+
var status = await Permission.notification.request();
8882
if (!status.isGranted) {
83+
Fluttertoast.showToast(
84+
msg: "알림 권한을 허용해주세요.",
85+
toastLength: Toast.LENGTH_SHORT,
86+
gravity: ToastGravity.CENTER,
87+
timeInSecForIosWeb: 1,
88+
backgroundColor: MySolvedColor.main.withOpacity(0.8),
89+
textColor: Colors.white,
90+
fontSize: 16.0);
91+
await Future.delayed(const Duration(seconds: 1));
92+
await openAppSettings();
8993
return;
9094
}
9195

@@ -144,7 +148,6 @@ class ContestBloc extends Bloc<ContestEvent, ContestState> {
144148
Emitter<ContestState> emit,
145149
) async {
146150
emit(state.copyWith(status: ContestStatus.loading));
147-
148151
final contest = state.filteredUpcomingContests[event.index];
149152
List<bool> isOnCalendar = state.isOnCalendarUpcomingContests;
150153
final isOn = await _sharedPreferencesRepository.getIsOnContestCalendar(

lib/features/setting/bloc/setting_bloc.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:fluttertoast/fluttertoast.dart';
45
import 'package:permission_handler/permission_handler.dart';
56
import 'package:shared_preferences_repository/shared_preferences_repository.dart';
67
import 'package:streak_notification_repository/streak_notification_repository.dart';
78

9+
import '../../../components/styles/color.dart';
10+
811
part 'setting_event.dart';
912
part 'setting_state.dart';
1013

@@ -96,15 +99,18 @@ class SettingBloc extends Bloc<SettingEvent, SettingState> {
9699
SettingStreakNotificationSwitchChanged event,
97100
Emitter<SettingState> emit,
98101
) async {
99-
var status = await Permission.notification.status;
100-
if (status.isDenied) {
101-
status = await Permission.notification.request();
102-
emit(state.copyWith(isOnStreakNotification: status.isGranted));
103-
} else if (status.isPermanentlyDenied) {
104-
await openAppSettings();
105-
emit(state.copyWith(isOnStreakNotification: status.isGranted));
106-
}
102+
var status = await Permission.notification.request();
107103
if (!status.isGranted) {
104+
Fluttertoast.showToast(
105+
msg: "알림 권한을 허용해주세요.",
106+
toastLength: Toast.LENGTH_SHORT,
107+
gravity: ToastGravity.CENTER,
108+
timeInSecForIosWeb: 1,
109+
backgroundColor: MySolvedColor.main.withOpacity(0.8),
110+
textColor: Colors.white,
111+
fontSize: 16.0);
112+
await Future.delayed(const Duration(seconds: 1));
113+
await openAppSettings();
108114
return;
109115
}
110116

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: For solving problems in the world of programming; base on solved.ac
33

44
publish_to: "none" # Remove this line if you wish to publish to pub.dev
55

6-
version: 2.2.1+82
6+
version: 2.2.1+85
77

88
environment:
99
sdk: ">=2.18.2 <3.0.0"

0 commit comments

Comments
 (0)