Skip to content

Commit 27568eb

Browse files
committed
feat: Forward push payload to our notification sdk
1 parent f7faf2c commit 27568eb

7 files changed

Lines changed: 792 additions & 72 deletions

File tree

stream-video-android-core/api/stream-video-android-core.api

Lines changed: 105 additions & 42 deletions
Large diffs are not rendered by default.

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ public open class DefaultNotificationHandler(
102102
}
103103
}
104104

105-
override fun onRingingCall(callId: StreamCallId, callDisplayName: String) {
105+
override fun onRingingCall(
106+
callId: StreamCallId,
107+
callDisplayName: String,
108+
payload: Map<String, Any?>,
109+
) {
106110
logger.d { "[onRingingCall] #ringing; callId: ${callId.id}" }
107111
CallService.showIncomingCall(
108112
application,
@@ -114,14 +118,19 @@ public open class DefaultNotificationHandler(
114118
callId,
115119
callDisplayName,
116120
shouldHaveContentIntent = true,
121+
payload,
117122
),
118123
)
119124
}
120125

121-
override fun onMissedCall(callId: StreamCallId, callDisplayName: String) {
126+
override fun onMissedCall(
127+
callId: StreamCallId,
128+
callDisplayName: String,
129+
payload: Map<String, Any?>,
130+
) {
122131
logger.d { "[onMissedCall] #ringing; callId: ${callId.id}" }
123132
val notificationId = callId.hashCode()
124-
val notification = getMissedCallNotification(callId, callDisplayName)
133+
val notification = getMissedCallNotification(callId, callDisplayName, payload)
125134
if (notification != null && ActivityCompat.checkSelfPermission(
126135
application,
127136
Manifest.permission.POST_NOTIFICATIONS,
@@ -137,6 +146,7 @@ public open class DefaultNotificationHandler(
137146
callId: StreamCallId,
138147
callDisplayName: String?,
139148
shouldHaveContentIntent: Boolean,
149+
payload: Map<String, Any?>,
140150
): Notification? {
141151
return if (ringingState is RingingState.Incoming) {
142152
val fullScreenPendingIntent = intentResolver.searchIncomingCallPendingIntent(callId)
@@ -150,6 +160,7 @@ public open class DefaultNotificationHandler(
150160
rejectCallPendingIntent,
151161
callDisplayName,
152162
shouldHaveContentIntent,
163+
payload,
153164
)
154165
} else {
155166
logger.e { "Ringing call notification not shown, one of the intents is null." }
@@ -164,6 +175,8 @@ public open class DefaultNotificationHandler(
164175
callId,
165176
callDisplayName,
166177
isOutgoingCall = true,
178+
0,
179+
payload,
167180
)
168181
} else {
169182
logger.e { "Ringing call notification not shown, one of the intents is null." }
@@ -177,6 +190,7 @@ public open class DefaultNotificationHandler(
177190
override fun getMissedCallNotification(
178191
callId: StreamCallId,
179192
callDisplayName: String?,
193+
payload: Map<String, Any?>,
180194
): Notification? {
181195
logger.d { "[getMissedCallNotification] callId: ${callId.id}, callDisplayName: $callDisplayName" }
182196
val notificationId = callId.hashCode()
@@ -275,16 +289,19 @@ public open class DefaultNotificationHandler(
275289
override suspend fun updateOngoingCallNotification(
276290
call: Call,
277291
callDisplayName: String,
292+
payload: Map<String, Any?>,
278293
): Notification? = null
279294

280295
override suspend fun updateOutgoingCallNotification(
281296
call: Call,
282297
callDisplayName: String?,
298+
payload: Map<String, Any?>,
283299
): Notification? = null
284300

285301
override suspend fun updateIncomingCallNotification(
286302
call: Call,
287303
callDisplayName: String,
304+
payload: Map<String, Any?>,
288305
): Notification? = null
289306

290307
override fun getIncomingCallNotification(
@@ -293,6 +310,7 @@ public open class DefaultNotificationHandler(
293310
rejectCallPendingIntent: PendingIntent,
294311
callerName: String?,
295312
shouldHaveContentIntent: Boolean,
313+
payload: Map<String, Any?>,
296314
): Notification {
297315
// if the app is in foreground then don't interrupt the user with a high priority
298316
// notification (popup). The application will display an incoming ringing call
@@ -366,7 +384,7 @@ public open class DefaultNotificationHandler(
366384
)
367385
}
368386

369-
override fun onNotification(callId: StreamCallId, callDisplayName: String) {
387+
override fun onNotification(callId: StreamCallId, callDisplayName: String, payload: Map<String, Any?>) {
370388
val notificationId = callId.hashCode()
371389
intentResolver.searchNotificationCallPendingIntent(callId, notificationId)
372390
?.let { notificationPendingIntent ->
@@ -378,7 +396,7 @@ public open class DefaultNotificationHandler(
378396
} ?: logger.e { "Couldn't find any activity for $ACTION_NOTIFICATION" }
379397
}
380398

381-
override fun onLiveCall(callId: StreamCallId, callDisplayName: String) {
399+
override fun onLiveCall(callId: StreamCallId, callDisplayName: String, payload: Map<String, Any?>) {
382400
val notificationId = callId.hashCode()
383401
intentResolver.searchLiveCallPendingIntent(callId, notificationId)
384402
?.let { liveCallPendingIntent ->
@@ -395,6 +413,7 @@ public open class DefaultNotificationHandler(
395413
callDisplayName: String?,
396414
isOutgoingCall: Boolean,
397415
remoteParticipantCount: Int,
416+
payload: Map<String, Any?>,
398417
): Notification? {
399418
val client = (StreamVideo.instance() as StreamVideoClient)
400419
val mediaNotificationCallTypes =
@@ -613,10 +632,28 @@ public open class DefaultNotificationHandler(
613632
}
614633
}
615634

635+
@Deprecated(
636+
"Use the one with payload: Map<String, Any?>",
637+
replaceWith = ReplaceWith("Use the one with payload: Map<String, Any?>"),
638+
)
639+
open fun showNotificationCallNotification(
640+
notificationPendingIntent: PendingIntent,
641+
callDisplayName: String,
642+
notificationId: Int,
643+
) {
644+
showNotificationCallNotification(
645+
notificationPendingIntent,
646+
callDisplayName,
647+
notificationId,
648+
emptyMap(),
649+
)
650+
}
651+
616652
open fun showNotificationCallNotification(
617653
notificationPendingIntent: PendingIntent,
618654
callDisplayName: String,
619655
notificationId: Int,
656+
payload: Map<String, Any?>,
620657
) {
621658
showNotification(notificationId) {
622659
setContentTitle("Incoming call")
@@ -625,21 +662,52 @@ public open class DefaultNotificationHandler(
625662
}
626663
}
627664

665+
@Deprecated(
666+
"Use the one with payload: Map<String, Any?>",
667+
replaceWith = ReplaceWith("Use the one with payload: Map<String, Any?>"),
668+
)
628669
open fun showMissedCallNotification(
629670
notificationPendingIntent: PendingIntent,
630671
callDisplayName: String,
631672
notificationId: Int,
673+
) {
674+
showMissedCallNotification(
675+
notificationPendingIntent,
676+
callDisplayName,
677+
notificationId,
678+
emptyMap(),
679+
)
680+
}
681+
682+
open fun showMissedCallNotification(
683+
notificationPendingIntent: PendingIntent,
684+
callDisplayName: String,
685+
notificationId: Int,
686+
payload: Map<String, Any?>,
632687
) {
633688
showNotification(notificationId) {
634689
setContentTitle("Missed call from $callDisplayName")
635690
setContentIntent(notificationPendingIntent)
636691
}
637692
}
638693

694+
@Deprecated(
695+
"Use the one with payload: Map<String, Any?>",
696+
replaceWith = ReplaceWith("Use the one with payload: Map<String, Any?>"),
697+
)
698+
open fun showLiveCallNotification(
699+
liveCallPendingIntent: PendingIntent,
700+
callDisplayName: String,
701+
notificationId: Int,
702+
) {
703+
showLiveCallNotification(liveCallPendingIntent, callDisplayName, notificationId, emptyMap())
704+
}
705+
639706
open fun showLiveCallNotification(
640707
liveCallPendingIntent: PendingIntent,
641708
callDisplayName: String,
642709
notificationId: Int,
710+
payload: Map<String, Any?>,
643711
) {
644712
showNotification(notificationId) {
645713
setContentTitle("Live Call")

0 commit comments

Comments
 (0)