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] 알람 해제 UX 개선 및 알람 권한 요청 #116

Merged
merged 8 commits into from
Feb 13, 2025

Conversation

DongChyeon
Copy link
Member

@DongChyeon DongChyeon commented Feb 13, 2025

Related issue 🛠

closed #115

어떤 변경사항이 있었나요?

  • 🐞 BugFix Something isn't working
  • 🎨 Design Markup & styling
  • 📃 Docs Documentation writing and editing (README.md, etc.)
  • ✨ Feature Feature
  • 🔨 Refactor Code refactoring
  • ⚙️ Setting Development environment setup
  • ✅ Test Test related (Junit, etc.)

CheckPoint ✅

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • PR 컨벤션에 맞게 작성했습니다. (필수)
  • merge할 브랜치의 위치를 확인해 주세요(main❌/develop⭕) (필수)
  • Approve된 PR은 assigner가 머지하고, 수정 요청이 온 경우 수정 후 다시 push를 합니다. (필수)
  • BugFix의 경우, 버그의 원인을 파악하였습니다. (선택)

Work Description ✏️

default.mp4
  • 푸시 알림에서 알람 해제 클릭 시 AlarmInteractionActivity 종료
  • AlarmInteractionActivity에서 새로운 알람 인텐트 수신 및 네비게이션 처리 추가
    • 이미 AlarmInteractionActivity에 있는 상태에서 새로운 푸시 알림을 클릭했을 때 해당 알람으로 정보 갱신
  • 잠금 화면에서 알람 수신 시 AlarmInteractionActivity가 실행 중이면 종료
  • 온보딩 과정에서 POST_NOTIFICATION 권한 요청 후 SCHEDULE_EXACT_ALARM 권한 요청

Uncompleted Tasks 😅

N/A

To Reviewers 📢

DisposableEffect(lifecycleOwner) {
        val observer = LifecycleEventObserver { _, event ->
            if (event == Lifecycle.Event.ON_RESUME) {
                isAlarmPermissionGranted = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                    val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as android.app.AlarmManager
                    alarmManager.canScheduleExactAlarms()
                } else {
                    true
                }
            }
        }
        lifecycleOwner.lifecycle.addObserver(observer)
        onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
    }

SCHEDULE_EXACT_ALARM 권한이 Accompanist Permission과 호환이 안되서 쌩으로 구현했습니다...
설정창에서 다시 앱으로 돌아왔을 때 권한을 체크해줘야 하는데, LaunchedEffect로는 처리가 안되길래
LifecycleEventObserver로 onResumse 상태가 될 때마다 검사했습니다.

@Composable
fun LaunchedEffectWithLifecycle(
    vararg keys: Any?,
    lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
    minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
    action: suspend CoroutineScope.() -> Unit = {},
) {
    LaunchedEffect(*keys) {
        lifecycleOwner.lifecycle.repeatOnLifecycle(minActiveState, action)
    }
}
  • LaunchedEffect(*keys)는 keys 값이 변경될 때만 다시 실행됨.
  • LifecycleOwner가 변경되었지만 keys 값이 동일하면 LaunchedEffect가 재실행되지 않음.
  • ON_STOP 이후 ON_CREATE가 빠르게 호출되며 LifecycleOwner가 새로 생성될 가능성이 있음.
  • 기존 repeatOnLifecycle이 중단된 상태에서 새로운 LifecycleOwner에서 실행되지 않을 수 있음.

image
실제로 LifeCycleObserver가 재등록된 후에는 작동하지 않았습니다.

LaunchedEffectWithLifeCycle은 해당 문제로 인해 삭제했습니다~

Copy link
Member

@MoonsuKang MoonsuKang left a comment

Choose a reason for hiding this comment

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

GOOD

Comment on lines 71 to 77
var hasRequestedPermission by remember { mutableStateOf(false) }
var hasCheckedNotification by remember { mutableStateOf(false) }
var hasCheckedAlarm by remember { mutableStateOf(false) }

var isAlarmPermissionGranted by remember { mutableStateOf(false) }

var hasDelayed by remember { mutableStateOf(false) }
Copy link
Member

@MoonsuKang MoonsuKang Feb 13, 2025

Choose a reason for hiding this comment

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

p4
rememberSaveable이 더 났지 않을까염?

Copy link
Member Author

Choose a reason for hiding this comment

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

그런듯여

Comment on lines 105 to 111
} else if (!isAlarmPermissionGranted && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !hasCheckedAlarm) {
hasCheckedAlarm = true
val intent = Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM).apply {
data = Uri.fromParts("package", context.packageName, null)
}
context.startActivity(intent)
}
Copy link
Member

Choose a reason for hiding this comment

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

p5
Dispatchers.Main으로 처리하는거 어떻게 생각하세요? 궁금함

Copy link
Member Author

Choose a reason for hiding this comment

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

오 그건 몰띾넹

@DongChyeon DongChyeon force-pushed the feat/#115-alarm-enhancement branch from 4793cfe to 902d33c Compare February 13, 2025 08:04
Copy link
Member

@MoonsuKang MoonsuKang left a comment

Choose a reason for hiding this comment

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

🤡

@DongChyeon DongChyeon merged commit f015cf7 into develop Feb 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 알람 해제 UX 개선 및 알람 권한 요청
2 participants