Skip to content

Commit becb3a2

Browse files
authored
Merge pull request #99 from EAT-SSU/feat/#96
[#96] 앱을 μ²˜μŒμ„€μΉ˜ν–ˆμ„ λ•Œ, OSμ—μ„œ ν‘Έμ‹œ μ•Œλ¦Ό λ™μ˜ μ‹œ μŠ€μœ„μΉ˜ λ²„νŠΌμ„ μΌœλ‘κ²Œ μ„€μ •
2 parents 289238f + 4dd417c commit becb3a2

File tree

6 files changed

+354
-379
lines changed

6 files changed

+354
-379
lines changed

β€ŽEATSSU_MVC/EATSSU_MVC/Sources/Notification/NotificationManager.swift

+44-50
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,65 @@ import Foundation
99
import UserNotifications
1010

1111
class NotificationManager {
12-
13-
// MARK: - Properties
14-
15-
static let shared = NotificationManager()
12+
// MARK: - Properties
1613

17-
// MARK: - Methods
14+
static let shared = NotificationManager()
1815

19-
/// 평일 11μ‹œμ— μ•±μ˜ μœ μž…μ„ μœ λ„ν•˜λŠ” ν‘Έμ‹œ μ•Œλ¦Όμ„ λ°œμ†‘ν•˜λŠ” λ©”μ†Œλ“œ
20-
///
21-
/// - Title : πŸ€” 였늘 λ°₯ 뭐 먹지…
22-
/// - Body : 였늘의 학식을 ν™•μΈν•΄λ³΄μ„Έμš”!
23-
func scheduleWeekday11AMNotification() {
24-
let center = UNUserNotificationCenter.current()
16+
// MARK: - Methods
2517

26-
// μ•Œλ¦Ό μ½˜ν…μΈ  μ„€μ •
27-
let content = UNMutableNotificationContent()
18+
/// 평일 11μ‹œμ— μ•±μ˜ μœ μž…μ„ μœ λ„ν•˜λŠ” ν‘Έμ‹œ μ•Œλ¦Όμ„ λ°œμ†‘ν•˜λŠ” λ©”μ†Œλ“œ
19+
///
20+
/// - Title : πŸ€” 였늘 λ°₯ 뭐 먹지…
21+
/// - Body : 였늘의 학식을 ν™•μΈν•΄λ³΄μ„Έμš”!
22+
func scheduleWeekday11AMNotification() {
23+
let center = UNUserNotificationCenter.current()
24+
25+
// μ•Œλ¦Ό μ½˜ν…μΈ  μ„€μ •
26+
let content = UNMutableNotificationContent()
2827

29-
content.title = TextLiteral.Notification.dailyWeekdayNotificationTitle
30-
content.body = TextLiteral.Notification.dailyWeekdayNotificationBody
31-
content.sound = .default
28+
content.title = TextLiteral.Notification.dailyWeekdayNotificationTitle
29+
content.body = TextLiteral.Notification.dailyWeekdayNotificationBody
30+
content.sound = .default
3231

33-
// λ°˜λ³΅ν•  μš”μΌ 및 μ‹œκ°„ μ„€μ • (평일 μ˜€μ „ 11μ‹œ)
34-
let weekdays = [2, 3, 4, 5, 6] // μ›”, ν™”, 수, λͺ©, 금 (Calendarμ—μ„œ 1이 μΌμš”μΌ)
32+
// λ°˜λ³΅ν•  μš”μΌ 및 μ‹œκ°„ μ„€μ • (평일 μ˜€μ „ 11μ‹œ)
33+
let weekdays = [2, 3, 4, 5, 6] // μ›”, ν™”, 수, λͺ©, 금 (Calendarμ—μ„œ 1이 μΌμš”μΌ)
3534

36-
for weekday in weekdays {
37-
var dateComponents = DateComponents()
38-
dateComponents.hour = 11
39-
dateComponents.minute = 0
40-
dateComponents.weekday = weekday
35+
for weekday in weekdays {
36+
var dateComponents = DateComponents()
37+
dateComponents.hour = 11
38+
dateComponents.minute = 0
39+
dateComponents.weekday = weekday
4140

42-
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
41+
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
4342

44-
// κ³ μœ ν•œ μ‹λ³„μžλ₯Ό μœ„ν•΄ weekdayλ₯Ό μ‚¬μš©
45-
let identifier = "weekdayNotification-\(weekday)"
46-
let request = UNNotificationRequest(
47-
identifier: identifier, content: content, trigger: trigger)
43+
// κ³ μœ ν•œ μ‹λ³„μžλ₯Ό μœ„ν•΄ weekdayλ₯Ό μ‚¬μš©
44+
let identifier = "weekdayNotification-\(weekday)"
45+
let request = UNNotificationRequest(
46+
identifier: identifier, content: content, trigger: trigger)
47+
48+
// μ•Œλ¦Ό 등둝
49+
center.add(request) { error in
50+
if let error = error {
51+
print("μ•Œλ¦Ό 등둝 κ°„ μ—λŸ¬ λ©”μ‹œμ§€: \(error.localizedDescription)")
52+
}
53+
}
54+
}
55+
}
4856

49-
// μ•Œλ¦Ό 등둝
50-
center.add(request) { error in
51-
if let error = error {
52-
print("μ•Œλ¦Ό 등둝 κ°„ μ—λŸ¬ λ©”μ‹œμ§€: \(error.localizedDescription)")
53-
}
54-
}
55-
}
56-
}
57-
5857
/// 평일 11μ‹œμ— μ•±μ˜ μœ μž…μ„ μœ λ„ν•˜λŠ” ν‘Έμ‹œ μ•Œλ¦Όμ„ μ·¨μ†Œν•˜λŠ” λ©”μ†Œλ“œ
5958
func cancelWeekday11AMNotification() {
6059
let weekday = [2, 3, 4, 5, 6]
6160
let identifier = "weekdayNotification-\(weekday)"
62-
61+
6362
let center = UNUserNotificationCenter.current()
6463
center.removePendingNotificationRequests(withIdentifiers: [identifier])
6564
}
6665

67-
/// μ•± μ‹€ν–‰ μ‹œ μ•Œλ¦Ό λ°œμ†‘ κΆŒν•œμ„ μš”μ²­ν•˜λŠ” νŒμ—… 호좜 λ©”μ†Œλ“œ
68-
func requestNotificationPermission() {
69-
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
70-
granted, error in
71-
if granted {
72-
print("μ•Œλ¦Ό κΆŒν•œ 승인됨")
73-
} else {
74-
print("μ•Œλ¦Ό κΆŒν•œ 거뢀됨")
75-
}
76-
}
77-
}
78-
66+
/// μ•± μ‹€ν–‰ μ‹œ μ•Œλ¦Ό λ°œμ†‘ κΆŒν•œμ„ μš”μ²­ν•˜λŠ” νŒμ—… 호좜 λ©”μ†Œλ“œ
67+
func requestNotificationPermission(completion: @escaping (_ granted : Bool) -> Void) {
68+
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
69+
granted, _ in
70+
completion(granted)
71+
}
72+
}
7973
}

β€ŽEATSSU_MVC/EATSSU_MVC/Sources/Presentation/MyPage/View/MyPageView/Cell/MyPageTableDefaultCell.swift

+33-34
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,53 @@ import UIKit
1010
import SnapKit
1111

1212
final class MyPageTableDefaultCell: UITableViewCell {
13+
// MARK: - Properties
1314

14-
// MARK: - Properties
15+
static let identifier = "MyPageTableDefaultCell"
1516

16-
static let identifier = "MyPageTableDefaultCell"
17+
// MARK: - UI Components
1718

18-
// MARK: - UI Components
19-
20-
let serviceLabel = UILabel().then {
19+
let serviceLabel = UILabel().then {
2120
$0.font = EATSSUFontFamily.Pretendard.medium.font(size: 16)
2221
$0.textColor = .black
23-
}
22+
}
2423

2524
let rigthChevronImage = UIImageView().then { imageView in
2625
imageView.image = UIImage(systemName: "chevron.right")
2726
imageView.tintColor = EATSSUAsset.Color.GrayScale.gray300.color
2827
}
2928

29+
// MARK: - Initializer
3030

31-
// MARK: - Initializer
32-
33-
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
34-
super.init(style: style, reuseIdentifier: reuseIdentifier)
31+
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
32+
super.init(style: style, reuseIdentifier: reuseIdentifier)
3533

36-
configureUI()
37-
setLayout()
38-
}
34+
configureUI()
35+
setLayout()
36+
}
3937

40-
required init?(coder: NSCoder) {
41-
fatalError("init(coder:) has not been implemented")
42-
}
38+
@available(*, unavailable)
39+
required init?(coder: NSCoder) {
40+
fatalError("init(coder:) has not been implemented")
41+
}
4342

44-
// MARK: - Functions
45-
46-
private func configureUI() {
47-
self.addSubviews(
48-
serviceLabel,
49-
rigthChevronImage
50-
)
51-
}
52-
53-
private func setLayout() {
54-
serviceLabel.snp.makeConstraints {
55-
$0.leading.equalToSuperview().offset(24)
56-
$0.centerY.equalToSuperview()
57-
}
43+
// MARK: - Functions
44+
45+
private func configureUI() {
46+
addSubviews(
47+
serviceLabel,
48+
rigthChevronImage
49+
)
50+
}
51+
52+
private func setLayout() {
53+
serviceLabel.snp.makeConstraints {
54+
$0.leading.equalToSuperview().offset(24)
55+
$0.centerY.equalToSuperview()
56+
}
5857
rigthChevronImage.snp.makeConstraints {
59-
$0.trailing.equalToSuperview().inset(24)
60-
$0.centerY.equalToSuperview()
61-
}
62-
}
58+
$0.trailing.equalToSuperview().inset(24)
59+
$0.centerY.equalToSuperview()
60+
}
61+
}
6362
}

β€ŽEATSSU_MVC/EATSSU_MVC/Sources/Presentation/MyPage/View/MyPageView/Cell/NotificationSettingTableViewCell.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import UIKit
1010
import SnapKit
1111

1212
class NotificationSettingTableViewCell: UITableViewCell {
13-
1413
// MARK: - Properties
14+
1515
static let identifier = "NotificationSettingTableViewCell"
1616

1717
// MARK: - UI Components
@@ -40,14 +40,13 @@ class NotificationSettingTableViewCell: UITableViewCell {
4040
return stackView
4141
}()
4242

43-
internal let toggleSwitch: UISwitch = {
43+
let toggleSwitch: UISwitch = {
4444
let toggleSwitch = UISwitch()
4545
toggleSwitch.onTintColor = EATSSUAsset.Color.Main.primary.color
4646
toggleSwitch.isOn = UserDefaults.standard.bool(forKey: TextLiteral.MyPage.pushNotificationUserSettingKey)
4747
return toggleSwitch
4848
}()
4949

50-
5150
// MARK: - Initializer
5251

5352
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -57,6 +56,7 @@ class NotificationSettingTableViewCell: UITableViewCell {
5756
setupLayout()
5857
}
5958

59+
@available(*, unavailable)
6060
required init?(coder: NSCoder) {
6161
fatalError("init(coder:) has not been implemented")
6262
}
@@ -85,5 +85,4 @@ class NotificationSettingTableViewCell: UITableViewCell {
8585
make.centerY.equalToSuperview()
8686
}
8787
}
88-
8988
}

0 commit comments

Comments
Β (0)