Skip to content

Commit

Permalink
[Fix/#100] 알림 권한 허용 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoncheong committed Jul 21, 2023
1 parent 3e7c041 commit 9165795
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,40 @@ class SetTimeActivity : BindingActivity<ActivitySetTimeBinding>(R.layout.activit
}

private fun askNotificationPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
) {
Snackbar.make(binding.root, R.string.allowing_notification, Snackbar.LENGTH_SHORT).show()
} else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
) {
Snackbar.make(binding.root, getString(R.string.allowing_notification), Snackbar.LENGTH_SHORT).show()
}

if (ContextCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS
) != PackageManager.PERMISSION_GRANTED){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){
if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
// 왜 알림을 허용해야 하는지에 대한 설명 + 권한 거절 시 권한 설정 화면으로 이동
Snackbar.make(
binding.root,
getString(R.string.if_allow_notification),
Snackbar.LENGTH_SHORT
).show()
val intent =
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + this.packageName))
startActivity(intent)
this.finish()
} else {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
else{
Snackbar.make(
binding.root,
R.string.if_allow_notification,
getString(R.string.setting_noti),
Snackbar.LENGTH_SHORT
).show()
val intent =
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + this.packageName))
startActivity(intent)
this.finish()
} else {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<string name="night">밤</string>
<string name="everyday_notification">매일 %s %d시에\n교신을 보내줄게</string>
<string name="everyday_notification_half">매일 %s %d시 반에\n교신을 보내줄게</string>
<string name="setting_noti">설정에서 알림을 설정하세요.</string>

<!-- quest activity-->
<string name="quest_progressbar_comment">거의 다 왔어! 조금만 힘내줘!</string>
Expand Down

0 comments on commit 9165795

Please sign in to comment.