-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feature/#68] : fcm, like api #72
Changes from all commits
0f7f218
0a73bad
4a8dd3d
158611f
68a3136
e72473e
295fe73
63b327b
7e49059
9f1aaa9
c70bd98
0f06c60
38248e8
7d2920b
b8f648f
a832ea8
987e20f
9d34ae1
4f232d1
f762007
20739a9
73691b4
f82fa72
25bcd3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,18 @@ | |
android:theme="@style/Theme.Wable" | ||
android:usesCleartextTraffic="true" | ||
tools:targetApi="31"> | ||
<meta-data | ||
android:name="com.google.firebase.messaging.default_notification_color" | ||
android:resource="@color/white" /> | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ΄λ²μ meta dataμ iconμΆκ° μ ν΄λ λλμ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μΆκ°ν΄μΌν©λλ€!!! μμ νλ€κ° λΉΌλκ³ μΆκ° μνλ€μ ..γ γ |
||
|
||
<service | ||
android:name=".service.WableFirebaseMessagingService" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service> | ||
|
||
<activity | ||
android:name="com.teamwable.main_compose.MainComposeActivity" | ||
android:exported="true"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.teamwable.wable.service | ||
|
||
import android.app.Notification | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.core.app.NotificationCompat | ||
import com.google.firebase.messaging.Constants.MessageNotificationKeys.ENABLE_NOTIFICATION | ||
import com.google.firebase.messaging.Constants.MessageNotificationKeys.NOTIFICATION_PREFIX | ||
import com.google.firebase.messaging.Constants.MessageNotificationKeys.NOTIFICATION_PREFIX_OLD | ||
import com.google.firebase.messaging.FirebaseMessagingService | ||
import com.google.firebase.messaging.RemoteMessage | ||
import com.teamwable.main.MainActivity | ||
import com.teamwable.ui.extensions.colorOf | ||
import com.teamwable.ui.util.FcmTag.CHANNEL_ID | ||
import com.teamwable.ui.util.FcmTag.NOTIFICATION_BODY | ||
import com.teamwable.ui.util.FcmTag.NOTIFICATION_TITLE | ||
import com.teamwable.ui.util.FcmTag.RELATED_CONTENT_ID | ||
import timber.log.Timber | ||
|
||
class WableFirebaseMessagingService : FirebaseMessagingService() { | ||
private lateinit var title: String | ||
private lateinit var body: String | ||
|
||
override fun onNewToken(token: String) { | ||
super.onNewToken(token) | ||
Timber.d("fcm new token : $token") | ||
} | ||
|
||
override fun onMessageReceived(message: RemoteMessage) { | ||
super.onMessageReceived(message) | ||
sendPushAlarm( | ||
title = if (::title.isInitialized) title else "", | ||
body = if (::body.isInitialized) body else "", | ||
contentId = message.data[RELATED_CONTENT_ID] ?: return, | ||
) | ||
} | ||
|
||
private fun sendPushAlarm(title: String, body: String, contentId: String) { | ||
val notificationManager = | ||
getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager | ||
val notification = buildNotification(title, body, contentId) | ||
notificationManager?.notify((System.currentTimeMillis()).toInt(), notification) | ||
} | ||
|
||
override fun handleIntent(intent: Intent?) { | ||
val newPushAlarmIntent = intent?.apply { | ||
val temp = extras?.apply { | ||
title = getString(NOTIFICATION_TITLE).orEmpty() | ||
body = getString(NOTIFICATION_BODY).orEmpty() | ||
remove(ENABLE_NOTIFICATION) | ||
remove(getKeyWithOldPrefix()) | ||
} | ||
replaceExtras(temp) | ||
} | ||
super.handleIntent(newPushAlarmIntent) | ||
} | ||
|
||
private fun getKeyWithOldPrefix(): String { | ||
val key = ENABLE_NOTIFICATION | ||
return if (!key.startsWith(NOTIFICATION_PREFIX)) { | ||
key | ||
} else { | ||
key.replace( | ||
NOTIFICATION_PREFIX, | ||
NOTIFICATION_PREFIX_OLD, | ||
) | ||
} | ||
} | ||
|
||
private fun buildNotification( | ||
title: String, | ||
body: String, | ||
contentId: String, | ||
): Notification { | ||
val pendingIntent = createPendingIntent(contentId) | ||
return NotificationCompat.Builder(this, CHANNEL_ID) | ||
.setSmallIcon(com.teamwable.common.R.drawable.ic_share_symbol) | ||
.setContentTitle(title) | ||
.setContentText(body) | ||
.setColor(colorOf(com.teamwable.ui.R.color.white)) | ||
.setPriority(NotificationCompat.PRIORITY_HIGH) | ||
.setContentIntent(pendingIntent) | ||
.setAutoCancel(true) | ||
.setShowWhen(true) | ||
.build() | ||
} | ||
|
||
private fun createPendingIntent(contentId: String): PendingIntent { | ||
val intent = Intent(this, MainActivity::class.java).apply { | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
putExtra(RELATED_CONTENT_ID, contentId) | ||
} | ||
return PendingIntent.getActivity( | ||
this, | ||
(System.currentTimeMillis()).toInt(), | ||
intent, | ||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE, | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@drawable/ic_launcher_background" /> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground" /> | ||
<monochrome android:drawable="@drawable/ic_launcher_foreground" /> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@drawable/ic_launcher_background" /> | ||
<foreground android:drawable="@drawable/ic_launcher_foreground" /> | ||
<monochrome android:drawable="@drawable/ic_launcher_foreground" /> | ||
<background android:drawable="@color/ic_launcher_background"/> | ||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/> | ||
</adaptive-icon> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#FFFFFF</color> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.teamwable.data.mapper.toData | ||
|
||
import com.teamwable.network.dto.request.RequestPostCommentLikeDto | ||
import com.teamwable.network.dto.request.RequestPostFeedLikeDto | ||
|
||
internal fun String.toPostFeedLikeDto(): RequestPostFeedLikeDto = | ||
RequestPostFeedLikeDto(this) | ||
|
||
internal fun Pair<String, String>.toPostCommentLikeDto(): RequestPostCommentLikeDto = | ||
RequestPostCommentLikeDto(first, second) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.teamwable.model | ||
|
||
data class LikeState( | ||
val isLiked: Boolean, | ||
val count: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ interface ProfileService { | |
@PATCH("api/v1/withdrawal") | ||
suspend fun patchWithdrawal(@Body requestWithdrawalDto: RequestWithdrawalDto): BaseUnitResponse<Unit> | ||
|
||
@Multipart | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 : μ! ν· |
||
@PATCH("api/v1/user-profile2") | ||
suspend fun patchUserProfile( | ||
@Part("info") requestProfileEdit: RequestBody, | ||
|
@@ -40,7 +41,6 @@ interface ProfileService { | |
@Query("nickname") nickname: String, | ||
): BaseUnitResponse<Unit> | ||
|
||
@Multipart | ||
@POST("api/v1/report/slack") | ||
suspend fun postReport( | ||
@Body request: RequestReportDto, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.teamwable.network.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestPostCommentLikeDto( | ||
@SerialName("notificationTriggerType") val notificationTriggerType: String, | ||
@SerialName("notificationText") val notificationText: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.teamwable.network.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestPostFeedLikeDto( | ||
@SerialName("alarmTriggerType") val alarmTriggerType: String, | ||
) |
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.
νΉμ μ΄κ±° μ΅μ λ²μ μμ λμκ°λμ? zν립6μμ fcmμμ€κΈΈλ λ²μ μ νλκΉ μ€κΈ΄ νμ΅λλ€
μ λ μ νν μμΈμ λͺ¨λ₯΄κ² μ΄μγ
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.
μμ§ νΈμμλ¦Ό μλ κ±°μμ γ .γ μμ μ€ γ γ λ€μ PRμμ μμ νκ² μ΅λλ€-!!