-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from JaesungLeee/develop
v1.1.0
- Loading branch information
Showing
128 changed files
with
3,144 additions
and
652 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
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "832727038255", | ||
"project_id": "keylink-731df", | ||
"storage_bucket": "keylink-731df.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:832727038255:android:2a36823f5b6835c29d09da", | ||
"android_client_info": { | ||
"package_name": "com.mashup.ssamd" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "832727038255-789jestndq3tqhosf2rj0lodgv06ii23.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.mashup.ssamd", | ||
"certificate_hash": "1519448b6407650d0d0e6d3fe0c2cb361ddeef68" | ||
} | ||
}, | ||
{ | ||
"client_id": "832727038255-dmmombtpj0n3rjihgu8nsk3didie2h97.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCYzKRoLm4ZdbAGgIJ9kgGtQQCLed_Q37M" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "832727038255-dmmombtpj0n3rjihgu8nsk3didie2h97.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:832727038255:android:bc5a57ee6437bce19d09da", | ||
"android_client_info": { | ||
"package_name": "com.mashup.ssamd.debug" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "832727038255-dmmombtpj0n3rjihgu8nsk3didie2h97.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCYzKRoLm4ZdbAGgIJ9kgGtQQCLed_Q37M" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "832727038255-dmmombtpj0n3rjihgu8nsk3didie2h97.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.mashup.ssamd | ||
|
||
import android.util.Log | ||
import com.google.firebase.messaging.FirebaseMessagingService | ||
import com.google.firebase.messaging.RemoteMessage | ||
import com.mashup.ssamd.notification.ShowPushNotificationUseCase | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Ssam_D_Android | ||
* @author jaesung | ||
* @created 2023/07/29 | ||
*/ | ||
@AndroidEntryPoint | ||
class KeyLinkService : FirebaseMessagingService() { | ||
|
||
@Inject | ||
lateinit var showPushNotificationUseCase: ShowPushNotificationUseCase | ||
|
||
override fun onNewToken(token: String) { | ||
super.onNewToken(token) | ||
Log.e("SSSS","Device Token : $token") | ||
} | ||
|
||
override fun onMessageReceived(remoteMessage: RemoteMessage) { | ||
super.onMessageReceived(remoteMessage) | ||
showPushNotificationUseCase.invoke(remoteMessage) | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/mashup/ssamd/notification/NotificationConfigs.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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.mashup.ssamd.notification | ||
|
||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.content.Context | ||
import android.os.Build | ||
import androidx.core.app.NotificationCompat | ||
import com.google.firebase.messaging.FirebaseMessagingService | ||
|
||
/** | ||
* Ssam_D_Android | ||
* @author jaesung | ||
* @created 2023/08/01 | ||
*/ | ||
object NotificationConfigs { | ||
|
||
private const val SIGNAL_CHANNEL_ID = "KeyLinkSignal" | ||
private const val SIGNAL_CHANNEL_NAME = "구독 키워드 시그널 도착 알림" | ||
private const val CHAT_CHANNEL_ID = "KeyLinkChat" | ||
private const val CHAT_CHANNEL_NAME = "채팅 도착 알림" | ||
|
||
fun notifyReceivedSignal( | ||
context: Context, | ||
setNotificationAttrs: NotificationCompat.Builder.() -> NotificationCompat.Builder | ||
) { | ||
initializeNotificationChannel(context) | ||
context.getNotificationManager().run { | ||
notify( | ||
(System.currentTimeMillis()/1000).toInt(), | ||
NotificationCompat.Builder( | ||
context, | ||
SIGNAL_CHANNEL_ID | ||
).setNotificationAttrs().build() | ||
) | ||
} | ||
} | ||
|
||
fun notifyNewChat( | ||
context: Context, | ||
setNotificationAttrs: NotificationCompat.Builder.() -> NotificationCompat.Builder | ||
) { | ||
initializeNotificationChannel(context) | ||
context.getNotificationManager().run { | ||
notify( | ||
(System.currentTimeMillis()/1000).toInt(), | ||
NotificationCompat.Builder( | ||
context, | ||
CHAT_CHANNEL_ID | ||
).setNotificationAttrs().build() | ||
) | ||
} | ||
} | ||
|
||
private fun initializeNotificationChannel(context: Context) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
context.getNotificationManager().run { | ||
val signalChannel = NotificationChannel( | ||
SIGNAL_CHANNEL_ID, | ||
SIGNAL_CHANNEL_NAME, | ||
NotificationManager.IMPORTANCE_HIGH | ||
) | ||
|
||
val chatChannel = NotificationChannel( | ||
CHAT_CHANNEL_ID, | ||
CHAT_CHANNEL_NAME, | ||
NotificationManager.IMPORTANCE_HIGH | ||
) | ||
createNotificationChannels(listOf(signalChannel, chatChannel)) | ||
} | ||
} | ||
} | ||
|
||
private fun Context.getNotificationManager(): NotificationManager { | ||
return getSystemService(FirebaseMessagingService.NOTIFICATION_SERVICE) as NotificationManager | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/mashup/ssamd/notification/ShowPushNotificationUseCase.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mashup.ssamd.notification | ||
|
||
import com.google.firebase.messaging.RemoteMessage | ||
import com.mashup.ssamd.notification.builder.NotificationBuilder | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Ssam_D_Android | ||
* @author jaesung | ||
* @created 2023/08/01 | ||
*/ | ||
class ShowPushNotificationUseCase @Inject constructor( | ||
private val notificationBuilder: NotificationBuilder | ||
) { | ||
operator fun invoke(remoteMessage: RemoteMessage) { | ||
val title = remoteMessage.data["title"].orEmpty() | ||
val body = remoteMessage.data["body"].orEmpty() | ||
val notificationType = remoteMessage.data["notiType"].orEmpty() | ||
val roomId = remoteMessage.data["roomId"].orEmpty() | ||
|
||
if (title != null && body != null && notificationType != null && roomId != null) { | ||
when (notificationType) { | ||
SIGNAL_TYPE -> notificationBuilder.showReceivedSignalNotification(title, body) | ||
CHAT_TYPE -> notificationBuilder.showNewChatNotification(title, body, roomId) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val SIGNAL_TYPE = "SIGNAL" | ||
private const val CHAT_TYPE = "CHAT" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/mashup/ssamd/notification/builder/NotificationBuilder.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mashup.ssamd.notification.builder | ||
|
||
/** | ||
* Ssam_D_Android | ||
* @author jaesung | ||
* @created 2023/08/01 | ||
*/ | ||
interface NotificationBuilder { | ||
|
||
fun showReceivedSignalNotification(title: String, body: String) | ||
|
||
fun showNewChatNotification(title: String, body: String, roomId: String) | ||
} |
88 changes: 88 additions & 0 deletions
88
app/src/main/java/com/mashup/ssamd/notification/builder/NotificationBuilderImpl.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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.mashup.ssamd.notification.builder | ||
|
||
import android.app.PendingIntent | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import androidx.core.app.NotificationCompat | ||
import com.mashup.presentation.navigation.MainActivity | ||
import com.mashup.ssamd.R | ||
import com.mashup.ssamd.notification.NotificationConfigs | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Ssam_D_Android | ||
* @author jaesung | ||
* @created 2023/08/01 | ||
*/ | ||
class NotificationBuilderImpl @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
) : NotificationBuilder { | ||
|
||
override fun showReceivedSignalNotification(title: String, body: String) { | ||
NotificationConfigs.notifyReceivedSignal(context) { | ||
setStyle(NotificationCompat.BigTextStyle().bigText(body)) | ||
setSmallIcon(R.mipmap.ic_launcher) | ||
setContentTitle(title) | ||
setContentText(body) | ||
priority = NotificationCompat.PRIORITY_HIGH | ||
setAutoCancel(true) | ||
setCategory(NotificationCompat.CATEGORY_MESSAGE) | ||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC) | ||
setContentIntent(makeSignalLauncherPendingIntent()) | ||
} | ||
} | ||
|
||
override fun showNewChatNotification(title: String, body: String, roomId: String) { | ||
NotificationConfigs.notifyNewChat(context) { | ||
setStyle(NotificationCompat.BigTextStyle().bigText(body)) | ||
setSmallIcon(R.mipmap.ic_launcher) | ||
setContentTitle(title) | ||
setContentText(body) | ||
priority = NotificationCompat.PRIORITY_HIGH | ||
setAutoCancel(true) | ||
setCategory(NotificationCompat.CATEGORY_MESSAGE) | ||
setVisibility(NotificationCompat.VISIBILITY_PUBLIC) | ||
setContentIntent(makeChatLauncherPendingIntent()) | ||
} | ||
} | ||
|
||
private fun createMainIntent(): Intent { | ||
return Intent(context, MainActivity::class.java).apply { | ||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK | ||
} | ||
} | ||
|
||
private fun makeChatLauncherPendingIntent(): PendingIntent { | ||
val intent = createMainIntent() | ||
val pendingIntentFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_ONE_SHOT | ||
} else { | ||
PendingIntent.FLAG_ONE_SHOT | ||
} | ||
|
||
return PendingIntent.getActivity( | ||
context, | ||
(System.currentTimeMillis()).toInt(), | ||
intent, | ||
pendingIntentFlags | ||
) | ||
} | ||
|
||
private fun makeSignalLauncherPendingIntent(): PendingIntent { | ||
val intent = createMainIntent() | ||
val pendingIntentFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_ONE_SHOT | ||
} else { | ||
PendingIntent.FLAG_ONE_SHOT | ||
} | ||
|
||
return PendingIntent.getActivity( | ||
context, | ||
(System.currentTimeMillis()).toInt(), | ||
intent, | ||
pendingIntentFlags | ||
) | ||
} | ||
} |
Oops, something went wrong.