-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 알림 설정 로직 구현 #566
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
Merged
feat: 알림 설정 로직 구현 #566
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
89c0c12
feat: 알림 뷰 xml 구현
m6z1 89c2769
feat: 알림 설정 뷰 토글 상태 로직 구현
m6z1 0185469
feat: 알림 권한 없을 경우 권한 설정 이동 다이얼로그 구현
m6z1 fa6d8a1
feat: 변경된 fcm 토큰 저장 api 수정
m6z1 dc90ed0
Merge branch 'develop' of https://github.com/Team-WSS/WSS-Android int…
m6z1 0325c73
feat: 토큰 만료 시 업데이트 로직 구현
m6z1 b6fa864
build: 불필요한 파일 제거
m6z1 bab3f81
feat: 뷰에서 완료 버튼 삭제
m6z1 3f0da6c
build: 불필요한 코드 제거
m6z1 3237f4f
feat: 알림 수신여부 api 연동
m6z1 9656b1d
fix: fcm service에 repository 의존성 수정
m6z1 69fdd3a
refactor: 토글 버튼 디바운스 적용
m6z1 7f0e34e
fix: 알림 수신여부 초기에 null 값 반환하는 에러 수정
m6z1 3219bc8
feat: 토글 버튼 디자인 반영
m6z1 b37a2db
Merge branch 'develop' of https://github.com/Team-WSS/WSS-Android int…
m6z1 956d937
feat: 푸시 알림 클릭 시 notificationId 값 전달
m6z1 5b4b39d
build: ktlint 포맷팅
m6z1 c91565b
build: ktlint 포맷팅
m6z1 f1d6be4
refactor: 푸시알림 수신 여부 네이밍 notificationPushEnabled로 통일
m6z1 51cb960
refactor: fcm 토큰 저장 로직 수정
m6z1 5757e1a
build: 불필요한 import 제거
m6z1 75997b7
fix: 기존 토큰과 다를 경우 로컬에도 fcm 토큰값 업데이트
m6z1 bc585bb
fix: 홈 화면 읽어야 할 알림 있을 때 아이콘 수정
m6z1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/into/websoso/data/remote/api/PushMessageApi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.into.websoso.data.remote.api | ||
|
|
||
| import com.into.websoso.data.remote.request.NotificationPushEnabledRequestDto | ||
| import com.into.websoso.data.remote.response.NotificationPushEnabledResponseDto | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.POST | ||
|
|
||
| interface PushMessageApi { | ||
| @GET("users/push-settings") | ||
| suspend fun getUserPushEnabled(): NotificationPushEnabledResponseDto | ||
|
|
||
| @POST("users/push-settings") | ||
| suspend fun postUserPushEnabled( | ||
| @Body notificationPushEnabledRequestDto: NotificationPushEnabledRequestDto, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/into/websoso/data/remote/request/NotificationPushEnabledRequestDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.into.websoso.data.remote.request | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class NotificationPushEnabledRequestDto( | ||
| @SerialName("isPushEnabled") | ||
| val isPushEnabled: Boolean, | ||
| ) |
10 changes: 10 additions & 0 deletions
10
...src/main/java/com/into/websoso/data/remote/response/NotificationPushEnabledResponseDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.into.websoso.data.remote.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class NotificationPushEnabledResponseDto( | ||
| @SerialName("isPushEnabled") | ||
| val isPushEnabled: Boolean, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/src/main/java/com/into/websoso/data/repository/PushMessageRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package com.into.websoso.data.repository | ||
|
|
||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import androidx.datastore.preferences.core.booleanPreferencesKey | ||
| import androidx.datastore.preferences.core.edit | ||
| import androidx.datastore.preferences.core.stringPreferencesKey | ||
| import com.into.websoso.data.remote.api.PushMessageApi | ||
| import com.into.websoso.data.remote.request.NotificationPushEnabledRequestDto | ||
| import kotlinx.coroutines.flow.first | ||
| import javax.inject.Inject | ||
|
|
||
| class PushMessageRepository | ||
| @Inject | ||
| constructor( | ||
| private val userRepository: UserRepository, | ||
| private val authRepository: AuthRepository, | ||
| private val userStorage: DataStore<Preferences>, | ||
| private val pushMessageApi: PushMessageApi, | ||
| ) { | ||
| suspend fun updateUserFCMToken(fcmToken: String) { | ||
| val storedToken = fetchUserFCMToken() | ||
| if (fcmToken == storedToken) { | ||
| return | ||
| } | ||
|
|
||
| saveUserFCMToken(fcmToken) | ||
| } | ||
|
|
||
| suspend fun saveUserFCMToken(fcmToken: String) { | ||
| userStorage.edit { preferences -> | ||
| preferences[USER_FCM_TOKEN_KEY] = fcmToken | ||
| } | ||
|
|
||
| saveUserFCMTokenToRemote(fcmToken) | ||
| } | ||
|
|
||
| private suspend fun saveUserFCMTokenToRemote(fcmToken: String) { | ||
| val deviceIdentifier = userRepository.fetchUserDeviceIdentifier() | ||
| authRepository.saveFCMToken(fcmToken, deviceIdentifier) | ||
| } | ||
|
|
||
| private suspend fun fetchUserFCMToken(): String { | ||
| val preferences = userStorage.data.first() | ||
| return preferences[USER_FCM_TOKEN_KEY] ?: "" | ||
| } | ||
|
|
||
| suspend fun saveNotificationPermissionFirstLaunched(value: Boolean) { | ||
| userStorage.edit { preferences -> | ||
| preferences[NOTIFICATION_PERMISSION_FIRST_LAUNCHED_KEY] = value | ||
| } | ||
| } | ||
|
|
||
| suspend fun fetchNotificationPermissionFirstLaunched() = | ||
| userStorage.data.first()[NOTIFICATION_PERMISSION_FIRST_LAUNCHED_KEY] ?: true | ||
|
|
||
| suspend fun fetchUserPushEnabled(): Boolean = pushMessageApi.getUserPushEnabled().isPushEnabled | ||
|
|
||
| suspend fun saveUserPushEnabled(isEnabled: Boolean) { | ||
| pushMessageApi.postUserPushEnabled( | ||
| notificationPushEnabledRequestDto = NotificationPushEnabledRequestDto( | ||
| isPushEnabled = isEnabled, | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| companion object { | ||
| val USER_FCM_TOKEN_KEY = stringPreferencesKey("USER_FCM_TOKEN") | ||
| val NOTIFICATION_PERMISSION_FIRST_LAUNCHED_KEY = | ||
| booleanPreferencesKey("NOTIFICATION_PERMISSION_FIRST_LAUNCHED") | ||
| } | ||
| } |
7 changes: 0 additions & 7 deletions
7
app/src/main/java/com/into/websoso/data/repository/UserFeedRepository.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
a: 생성자주입 안받는 이유가 있나요 ?
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.
생성자 주입하면 푸시 알림 왔을 때 여기서 터지더라구요