Skip to content

Commit 46c27be

Browse files
committed
Add Live Updates promotion eligibility changes
Change-Id: I6d1c1c9a1701f08eea752140d3e9bd073e131438
1 parent 96700ce commit 46c27be

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

samples/user-interface/live-updates/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
-->
1717

1818
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
19-
19+
<!--Permission for posting notifications-->
2020
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
21-
21+
<!--Permission for live update eligibility-->
22+
<uses-permission android:name="POST_PROMOTED_NOTIFICATIONS" />
2223
</manifest>

samples/user-interface/live-updates/src/main/java/com/example/platform/ui/live_updates/SnackbarNotificationManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.app.NotificationManager.IMPORTANCE_DEFAULT
2424
import android.content.Context
2525
import android.graphics.Color
2626
import android.os.Build
27+
import android.os.Bundle
2728
import android.os.Handler
2829
import android.os.Looper
2930
import androidx.annotation.RequiresApi
@@ -188,10 +189,13 @@ object SnackbarNotificationManager {
188189

189190
@RequiresApi(Build.VERSION_CODES.O)
190191
fun buildBaseNotification(appContext: Context, orderState: OrderState): Notification.Builder {
191-
var notificationBuilder = Notification.Builder(appContext, CHANNEL_ID)
192+
val promotedExtras = Bundle()
193+
promotedExtras.putBoolean("android.requestPromotedOngoing", true)
194+
val notificationBuilder = Notification.Builder(appContext, CHANNEL_ID)
192195
.setSmallIcon(R.drawable.ic_launcher_foreground)
193196
.setOngoing(true)
194197
.setColorized(true)
198+
.addExtras(promotedExtras)
195199

196200
when (orderState) {
197201
INITIALIZING -> {}

0 commit comments

Comments
 (0)