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

[AN/USER] feat: fcm 푸시 알림 구현 (#522) #537

Merged
merged 17 commits into from
Oct 17, 2023
Merged

[AN/USER] feat: fcm 푸시 알림 구현 (#522) #537

merged 17 commits into from
Oct 17, 2023

Conversation

EmilyCh0
Copy link
Member

📌 관련 이슈

✨ PR 세부 내용

  • 축제 입장 알림 받을 수 있도록 푸시 알림 구현했습니다.
  • 알림 권한 요청은 HomeActivity에서 진행합니다.

@EmilyCh0 EmilyCh0 added AN 안드로이드에 관련된 작업 USER labels Oct 13, 2023
@EmilyCh0 EmilyCh0 self-assigned this Oct 13, 2023
@github-actions github-actions bot requested review from re4rk and SeongHoonC October 13, 2023 06:52
Copy link
Collaborator

@re4rk re4rk 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 25 to 31
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val channel = NotificationChannel(
FcmMessageType.ENTRY_ALERT.channelId,
getString(R.string.entry_alert_channel_name),
NotificationManager.IMPORTANCE_DEFAULT
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val channel = NotificationChannel(
FcmMessageType.ENTRY_ALERT.channelId,
getString(R.string.entry_alert_channel_name),
NotificationManager.IMPORTANCE_DEFAULT
)
val channel = NotificationChannel(
FcmMessageType.ENTRY_ALERT.channelId,
getString(R.string.entry_alert_channel_name),
NotificationManager.IMPORTANCE_DEFAULT
)
val notificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

사용하기 직전에 꺼내오는 것이 어떨까요??

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 39 to 42
if (ActivityCompat.checkSelfPermission(
context,
android.Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
Copy link
Collaborator

Choose a reason for hiding this comment

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

이부분도 PermissionUtil안에서 Activity.Compat.checkPermission으로 빼내는 것이 어떨까요??

Copy link
Member Author

Choose a reason for hiding this comment

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

반영완료!


ENTRY_PROCESS.channelId -> {
runBlocking {
// TODO: 입장완료 로직인지 확인하는 로직 추가 필요
Copy link
Collaborator

Choose a reason for hiding this comment

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

ENTRY_PROCESS.channelId으로 입력받았을 때 이 TODO가 해결 됐다고 생각하는데 어떻게 보시나요??

Copy link
Member Author

Choose a reason for hiding this comment

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

주석 삭제했습니다


override fun onMessageReceived(remoteMessage: RemoteMessage) {
when (remoteMessage.notification?.channelId) {
ENTRY_ALERT.channelId -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

processEntryAlerthandleEntryAlert로 빼내는 것은 어떤가요??

Copy link
Member Author

Choose a reason for hiding this comment

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

반영완료!

Copy link
Collaborator

@re4rk re4rk left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!👍

Copy link
Member

@SeongHoonC SeongHoonC 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 +16 to +25
private val intent = HomeActivity.getIntent(context).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK
}

private val pendingIntent = PendingIntent.getActivity(
context,
HOME_REQUEST_CODE,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
Copy link
Member

Choose a reason for hiding this comment

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

entryAlertNotificationBuilder 를 초기화하기 위해서만 필요한 것 같아요!
프로퍼티로 있는 이유가 있을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

아까 논의한대로 프로퍼티로 가지고 있을 필요는 없지만 싱글톤으로 관리하기 위해서 이대로 둘게요!


class TicketEntryService : FirebaseMessagingService() {

private val notificationManager by lazy { NotificationManager(this) }
Copy link
Member

Choose a reason for hiding this comment

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

Firebase Service 도 힐트로 주입할 수 있나요?

Comment on lines 29 to 40
private val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission(),
) { isGranted: Boolean ->
if (!isGranted) {
Toast.makeText(
this,
getString(R.string.home_notification_permission_denied),
Toast.LENGTH_SHORT
).show()
}
}

Copy link
Member

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.

함수로 분리해서 내부 프로퍼티 제거했습니다!

Copy link
Member

@SeongHoonC SeongHoonC left a comment

Choose a reason for hiding this comment

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

LGTM!

@SeongHoonC SeongHoonC merged commit 267333d into dev Oct 17, 2023
1 check passed
@SeongHoonC SeongHoonC deleted the feat/#522 branch October 17, 2023 01:14
BGuga pushed a commit that referenced this pull request Oct 17, 2023
* feat: 공연 입장 푸시 알림 구현

* refactor: FcmMessageType 분리

* refactor: NotificationManager 분리

* refactor: application에서 채널 생성

* fix: 포그라운드 푸시 알림 버그 해결

* refactor: 알림 권한 거부 메시지 문자열 추출

* refactor: ktlintCheck

* move: fcm 관련 파일 패키지 변경

* refactor: 알림 권한 메서드 분리

* refactor: ktlintcheck

* refactor: notificationManager 코드 순서 변경

* refactor: 불필요한 주석 제거

* refactor: 메서드 분리

* refactor: 알림 권한 확인 메서드 분리

* refactor: 알림 권한 요청 메서드 분리

* refactor: ktlintcheck
BGuga pushed a commit that referenced this pull request Oct 17, 2023
* feat: 공연 입장 푸시 알림 구현

* refactor: FcmMessageType 분리

* refactor: NotificationManager 분리

* refactor: application에서 채널 생성

* fix: 포그라운드 푸시 알림 버그 해결

* refactor: 알림 권한 거부 메시지 문자열 추출

* refactor: ktlintCheck

* move: fcm 관련 파일 패키지 변경

* refactor: 알림 권한 메서드 분리

* refactor: ktlintcheck

* refactor: notificationManager 코드 순서 변경

* refactor: 불필요한 주석 제거

* refactor: 메서드 분리

* refactor: 알림 권한 확인 메서드 분리

* refactor: 알림 권한 요청 메서드 분리

* refactor: ktlintcheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AN 안드로이드에 관련된 작업 USER
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[AN] fcm 푸시 알림 구현
3 participants