-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Feat [#51] 스크린 타임 앱 잠금 관련 이슈 해결 #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좀만 더 힘을 내봅시다!!
화이팅 👏🏽
func scheduleAppRefresh() { | ||
let request = BGAppRefreshTaskRequest(identifier: taskIdentifier) | ||
|
||
// 한국 시간으로 23:59 설정 | ||
var calendar = Calendar(identifier: .gregorian) | ||
calendar.timeZone = TimeZone(identifier: "Asia/Seoul")! | ||
let now = Date() | ||
let nowComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: now) | ||
|
||
if let nextMidnight = calendar.date(bySettingHour: 23, minute: 59, second: 0, of: now) { | ||
request.earliestBeginDate = nextMidnight > now ? nextMidnight : calendar.date(byAdding: .day, value: 1, to: nextMidnight) | ||
} | ||
|
||
do { | ||
try BGTaskScheduler.shared.submit(request) | ||
print("Scheduled app refresh for: \(String(describing: request.earliestBeginDate))") | ||
} catch { | ||
print("Could not schedule app refresh: \(error)") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BGAppRefreshTask이 기능을 썻을 때,
제가 잘못구현해서인지... 아니면 애플 측에서 좀 시간 오차가 있는지 모르겠지만
원하는 시간에 동작 실행이 안되더라고요..
그래서 저는 아예 쌩 타이머를 거는 방식으로 해놨었는데,
혹시 작동이 잘 되나요.? 테스트 해보기도 어렵더라고요..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 저도 아직 테스트 중이긴 한데, BGAppRefreshTask는 원래 정확한 시간에 동작 실행이 어렵다고 하더라구요
원인은 배터리 효율, 백그라운드 작업 등등 다양해서 거기에 대비하기도 어렵구요,,
그래서 저희 서비스의 실패 상황은 "스크린타임으로 잠긴 어플을 포인트를 이용해서 해제 했을 경우"만 있기 때문에 이 부분에 대해서만 저장할 예정입니다!
그냥 하루에 한번 실행되는 작업이다 정도로 사용될 예정입니다!
👾 작업 내용
🚀 PR Point
HMH_iOS/HMH_iOS/DeviceActivityMonitor/DeviceActivityMonitorExtension.swift
Lines 33 to 36 in 2288225
✅ CheckList
🔗 Issue
Resolved #51