Skip to content
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

Merged
merged 18 commits into from
Jun 12, 2024

Conversation

Zoe0929
Copy link
Member

@Zoe0929 Zoe0929 commented Jun 12, 2024

👾 작업 내용

  1. 스크린 타임 사용 종료 되었을 때 앱 잠금 후, 자정에 풀리지 않는 문제 해결
  2. 앱 통계(홈뷰)에서 남은 시간 그래프 표기 오류
  3. 11:59에 당일 데이터 전송하는 기능 구현 (Test )
  4. 전체적인 코드 정리

🚀 PR Point

  1. 스크린타임 사용 종료 시 자정에 해제되지 않는 문제를 해결했습니다. 설정해둔 일정이 끝나게 되면 잠금 앱 목록을 초기화하여 앱 잠금을 해제했습니다.
    override func intervalDidEnd(for activity: DeviceActivityName) {
    super.intervalDidEnd(for: activity)
    store.shield.applications = nil
    }
  2. 전체적으로 Xcode에서 경고 뜨는 구문들을 한 번씩 점검했습니다.
  3. 자정 정보 전송 테스트가 너무 어렵네요 😨
  • 해당 기능은 PR 단위가 너무 커지는 것을 방지하기 위해 다음 이슈에서 추가로 진행하겠습니다!

✅ CheckList

  • 오류 없이 빌드되는지 확인
  • 로그용 print문 제거
  • 불필요한 주석 제거
  • 코드 컨벤션 확인

🔗 Issue

Resolved #51

@Zoe0929 Zoe0929 added 🐰지희 지희의 issue ✨FEAT 기능 구현 labels Jun 12, 2024
@Zoe0929 Zoe0929 requested a review from kim-seonwoo June 12, 2024 03:16
@Zoe0929 Zoe0929 self-assigned this Jun 12, 2024
@Zoe0929 Zoe0929 linked an issue Jun 12, 2024 that may be closed by this pull request
Copy link
Member

@kim-seonwoo kim-seonwoo left a comment

Choose a reason for hiding this comment

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

좀만 더 힘을 내봅시다!!
화이팅 👏🏽

Comment on lines +60 to +79
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)")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

BGAppRefreshTask이 기능을 썻을 때,
제가 잘못구현해서인지... 아니면 애플 측에서 좀 시간 오차가 있는지 모르겠지만

원하는 시간에 동작 실행이 안되더라고요..

그래서 저는 아예 쌩 타이머를 거는 방식으로 해놨었는데,
혹시 작동이 잘 되나요.? 테스트 해보기도 어렵더라고요..

Copy link
Member Author

Choose a reason for hiding this comment

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

요거 저도 아직 테스트 중이긴 한데, BGAppRefreshTask는 원래 정확한 시간에 동작 실행이 어렵다고 하더라구요
원인은 배터리 효율, 백그라운드 작업 등등 다양해서 거기에 대비하기도 어렵구요,,
그래서 저희 서비스의 실패 상황은 "스크린타임으로 잠긴 어플을 포인트를 이용해서 해제 했을 경우"만 있기 때문에 이 부분에 대해서만 저장할 예정입니다!

그냥 하루에 한번 실행되는 작업이다 정도로 사용될 예정입니다!

@Zoe0929 Zoe0929 merged commit c365718 into develop Jun 12, 2024
@Zoe0929 Zoe0929 changed the title [Feat/#51] 스크린 타임 앱 잠금 관련 이슈 해결 Feat [#51] 스크린 타임 앱 잠금 관련 이슈 해결 Jun 16, 2024
@Zoe0929 Zoe0929 deleted the feat/#51-lockAll branch June 19, 2024 02:22
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
✨FEAT 기능 구현 🐰지희 지희의 issue
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feat] 앱 잠금 구현
2 participants