Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] local notification #202

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions KkuMulKum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
789D73A72C46AF4900C7077D /* KeychainService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789D73A62C46AF4900C7077D /* KeychainService.swift */; };
789D73AD2C46C19500C7077D /* ProfileModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789D73AC2C46C19500C7077D /* ProfileModel.swift */; };
789D73AF2C46D99B00C7077D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 789D73AE2C46D99B00C7077D /* GoogleService-Info.plist */; };
789D73B32C47CC6D00C7077D /* LocalNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789D73B22C47CC6D00C7077D /* LocalNotificationManager.swift */; };
78AED1342C3D951F000AD80A /* NicknameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78AED1332C3D951F000AD80A /* NicknameViewController.swift */; };
78AED1372C3D98D1000AD80A /* NicknameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78AED1362C3D98D1000AD80A /* NicknameView.swift */; };
78B9286C2C29402C006D9942 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78B9286B2C29402C006D9942 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -234,6 +235,7 @@
789D73AC2C46C19500C7077D /* ProfileModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileModel.swift; sourceTree = "<group>"; };
789D73AE2C46D99B00C7077D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
789D73B02C46DACD00C7077D /* KkuMulKum.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = KkuMulKum.entitlements; sourceTree = "<group>"; };
789D73B22C47CC6D00C7077D /* LocalNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNotificationManager.swift; sourceTree = "<group>"; };
78AED1332C3D951F000AD80A /* NicknameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameViewController.swift; sourceTree = "<group>"; };
78AED1362C3D98D1000AD80A /* NicknameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameView.swift; sourceTree = "<group>"; };
78B928682C29402C006D9942 /* KkuMulKum.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KkuMulKum.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -513,6 +515,14 @@
path = ViewController;
sourceTree = "<group>";
};
789D73B12C47C81400C7077D /* Notification */ = {
isa = PBXGroup;
children = (
789D73B22C47CC6D00C7077D /* LocalNotificationManager.swift */,
);
path = Notification;
sourceTree = "<group>";
};
78AED1322C3D9514000AD80A /* Nickname */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1163,6 +1173,7 @@
DE254AA32C31107C00A4015E /* Resource */ = {
isa = PBXGroup;
children = (
789D73B12C47C81400C7077D /* Notification */,
78BD612D2C456162005752FD /* KeyChain */,
78BD612C2C455680005752FD /* Bundle */,
A3DD9C642C45B30600E58A13 /* Service */,
Expand Down Expand Up @@ -1692,6 +1703,7 @@
DE32D1D42C3BFB56006848DF /* UpdateProfileNameModel.swift in Sources */,
DE6D4D132C3F14D80005584B /* MeetingMemberCell.swift in Sources */,
DDAF1C932C3D6E3D008A37D3 /* PagePromiseViewController.swift in Sources */,
789D73B32C47CC6D00C7077D /* LocalNotificationManager.swift in Sources */,
DE9E18922C3BCC9D00DB76B4 /* SocialLoginRequestModel.swift in Sources */,
DE254AA82C3118EA00A4015E /* UIView+.swift in Sources */,
DD3976732C41B6C800E2A4C4 /* MockCreateMeetingService.swift in Sources */,
Expand Down
38 changes: 38 additions & 0 deletions KkuMulKum/Resource/Notification/LocalNotificationManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// LocalNotificationManager.swift
// KkuMulKum
//
// Created by μ΄μ§€ν›ˆ on 7/17/24.
//

import Foundation
import UserNotifications

class LocalNotificationManager {

private let notificationCenter = UNUserNotificationCenter.current()

func requestAuthorization(completion: @escaping (Bool) -> Void) {
notificationCenter.requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
completion(granted)
}
}

func scheduleNotification(title: String, body: String, triggerDate: Date) {
let content = UNMutableNotificationContent()
content.title = title
content.body = body
content.sound = .default

let components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: triggerDate)
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false)

let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)

notificationCenter.add(request) { error in
if let error = error {
print("Error scheduling notification: \(error)")
}
}
}
Comment on lines +21 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‹œκ°„ 계산 λ‘œμ§μ€ μ§€ν›ˆλ‹˜μ΄ κ΅¬ν˜„ν•˜μ‹œκΈ°λ‘œ κ²°μ •λœκ±΄κ°€μš”?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν˜Ήμ‹œλͺ°λΌμ„œ 일단 기쑴에 μž‘μ„±ν•œ λ‘œμ§μ„ ν†΅μ±„λ‘œ λ„£μ–΄λ‘”κ±°κΈ΄
μ €μž₯된 μ‹œκ°„κ³Ό κ³„μ‚°λœ λ‘œμ§μ„ λ°›μ•„μ˜€κΈ°λ§Œ ν•˜λ©΄ 될것같아 μˆ˜μ—°μœ μ§„ 두뢄 μ½”λ“œ 확인후 μΆ”ν›„ μ‚­μ œ κ°€λŠ₯μ„± μžˆμŠ΅λ‹ˆλ‹€

}