-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Feature Updates - μ±μ΄ Foregroundμ μμ΄λ μλ¦Όμ΄ μ€κ²λ μ§μ π§ Bug Fixes - λͺ©ν κ°κ²© μ€μ λ²μκ° 0~999999999 μ¬μ΄μμ μ€μ λλλ‘ μμ - μν μμΈ νμ΄μ§ μ λͺ© μ΅λ μ€ μλ₯Ό 3μ€λ‘ λ³κ²½ Co-Authored-By: EunhoKang <[email protected]> Co-Authored-By: ootr47 <[email protected]> Co-Authored-By: μλ¬ΈκΈ° <[email protected]> Co-Authored-By: ByeongIk Choi <[email protected]>
- Loading branch information
1 parent
be7fe31
commit 88d9dc1
Showing
14 changed files
with
273 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
100 changes: 100 additions & 0 deletions
100
android/app/src/main/java/app/priceguard/service/PriceGuardFirebaseMessagingService.kt
This file contains 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 |
---|---|---|
@@ -1,11 +1,111 @@ | ||
package app.priceguard.service | ||
|
||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.graphics.Bitmap | ||
import android.graphics.drawable.Drawable | ||
import android.media.RingtoneManager | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.util.Log | ||
import androidx.core.app.NotificationCompat | ||
import app.priceguard.R | ||
import app.priceguard.ui.detail.DetailActivity | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.request.target.CustomTarget | ||
import com.bumptech.glide.request.transition.Transition | ||
import com.google.firebase.messaging.FirebaseMessagingService | ||
import com.google.firebase.messaging.RemoteMessage | ||
|
||
class PriceGuardFirebaseMessagingService : FirebaseMessagingService() { | ||
// Init μμλ νΈμΆλ¨ | ||
override fun onNewToken(token: String) { | ||
Log.d("PriceGuardFirebaseMessagingService", "Refreshed token: $token") | ||
} | ||
|
||
override fun onMessageReceived(message: RemoteMessage) { | ||
super.onMessageReceived(message) | ||
message.notification?.let { | ||
sendNotification( | ||
it.title ?: return, | ||
it.body ?: return, | ||
it.imageUrl ?: return, | ||
message.data["productCode"] ?: return | ||
) | ||
} | ||
} | ||
|
||
private fun sendNotification(title: String, body: String, imageUrl: Uri, data: String) { | ||
val intent = Intent(this, DetailActivity::class.java) | ||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
intent.putExtra("productCode", data) | ||
intent.putExtra("directed", true) | ||
|
||
val requestCode = getRequestCode() | ||
val pendingIntent = PendingIntent.getActivity( | ||
this, | ||
requestCode, | ||
intent, | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE | ||
} else { | ||
PendingIntent.FLAG_UPDATE_CURRENT | ||
} | ||
) | ||
|
||
Glide.with(applicationContext) | ||
.asBitmap() | ||
.load(imageUrl) | ||
.into(object : CustomTarget<Bitmap>() { | ||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { | ||
buildNotification(title, body, resource, pendingIntent, requestCode) | ||
} | ||
|
||
override fun onLoadCleared(placeholder: Drawable?) {} | ||
}) | ||
} | ||
|
||
private fun buildNotification( | ||
title: String, | ||
body: String, | ||
image: Bitmap, | ||
pendingIntent: PendingIntent, | ||
requestCode: Int | ||
) { | ||
val channelId = getString(R.string.price_notification) | ||
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) | ||
val notificationBuilder = NotificationCompat.Builder(this, channelId) | ||
.setSmallIcon(R.drawable.ic_priceguard_notification) | ||
.setContentTitle(title) | ||
.setContentText(body) | ||
.setAutoCancel(true) | ||
.setSound(defaultSoundUri) | ||
.setLargeIcon(image) | ||
.setStyle(NotificationCompat.BigPictureStyle().bigPicture(image)) | ||
.setContentIntent(pendingIntent) | ||
|
||
val notificationManager = | ||
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | ||
|
||
val channel = NotificationChannel( | ||
channelId, | ||
getString(R.string.priceguard_push_alarm_title), | ||
NotificationManager.IMPORTANCE_DEFAULT | ||
) | ||
notificationManager.createNotificationChannel(channel) | ||
|
||
notificationManager.notify(requestCode, notificationBuilder.build()) | ||
} | ||
|
||
companion object { | ||
private var requestCode = 0 | ||
|
||
fun getRequestCode(): Int { | ||
requestCode = (requestCode + 1) % 100 | ||
return requestCode | ||
} | ||
} | ||
} |
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
.../app/priceguard/ui/ErrorDialogFragment.kt β ...priceguard/ui/util/ErrorDialogFragment.kt
This file contains 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 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 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 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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
December 12, 2023 | ||
v0.3.2 | ||
December 14, 2023 | ||
v1.0.0 | ||
|
||
π Feature Updates | ||
|
||
- μ±μ΄ Foregroundμ μμ΄λ μλ¦Όμ΄ μ€κ²λ μ§μ | ||
|
||
|
||
π§ Bug Fixes | ||
|
||
- 곡μ νκΈ°λ‘ μν λ±λ‘ μλ£ ν μ±μ΄ κΊΌμ§λ νμ μμ | ||
- μν μ€λ³΅ λ±λ‘ μ ν νλ©΄μΌλ‘ λμκ°λλ‘ μμ | ||
- μν μμ μ μμΈνλ©΄μΌλ‘ λμκ°λλ‘ μμ | ||
- μμνλ©΄, λ‘κ·ΈμΈ νλ©΄μμ κΈμ¨ ν¬κΈ° μ΄κ³Ό μ ν μ€νΈ ν¬κΈ° μλ μ‘°μ | ||
- λͺ©ν κ°κ²© μ€μ λ²μκ° 0~999999999 μ¬μ΄μμ μ€μ λλλ‘ μμ | ||
- μν μμΈ νμ΄μ§ μ λͺ© μ΅λ μ€ μλ₯Ό 3μ€λ‘ λ³κ²½ |
This file contains 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 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 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 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 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