TrustedWebActivityServiceWrapper
open class TrustedWebActivityServiceWrapper
kotlin.Any | |
↳ | androidx.browser.trusted.TrustedWebActivityServiceWrapper |
TrustedWebActivityServiceWrapper is used by a Trusted Web Activity provider to wrap calls to the TrustedWebActivityService
in the client app. All of these calls except getComponentName()
forward over IPC to corresponding calls on TrustedWebActivityService
, eg getSmallIconId()
forwards to TrustedWebActivityService#getSmallIconId()
.
These IPC calls are synchronous, though the TrustedWebActivityService
method may hit the disk. Therefore it is recommended to call them on a background thread (without StrictMode).
Summary
Public methods |
|
---|---|
open Boolean |
areNotificationsEnabled(@NonNull channelName: String) Checks whether notifications are enabled. |
open Unit |
Requests a notification be cancelled. |
open ComponentName |
Gets the |
open Bitmap? |
Requests a bitmap of a small icon to be used for the notification small icon. |
open Int |
Requests an Android resource id to be used for the notification small icon. |
open Boolean |
notify(@NonNull platformTag: String, platformId: Int, @NonNull notification: Notification, @NonNull channel: String) Requests a notification be shown. |
Public methods
areNotificationsEnabled
open fun areNotificationsEnabled(@NonNull channelName: String): Boolean
Checks whether notifications are enabled.
Parameters | |
---|---|
channelName |
String: The name of the channel to check enabled status. Only used on Android O+. |
Return | |
---|---|
Boolean: Whether notifications or the notification channel is blocked for the client app. |
cancel
open fun cancel(@NonNull platformTag: String, platformId: Int): Unit
Requests a notification be cancelled.
Parameters | |
---|---|
platformTag |
String: The tag to identify the notification. |
platformId |
String: The id to identify the notification. |
Exceptions | |
---|---|
SecurityException |
If verification with the TrustedWebActivityService fails. |
getComponentName
@NonNull open fun getComponentName(): ComponentName
Gets the ComponentName
of the connected Trusted Web Activity client app.
Return | |
---|---|
ComponentName: The Trusted Web Activity client app component name. |
getSmallIconBitmap
@Nullable open fun getSmallIconBitmap(): Bitmap?
Requests a bitmap of a small icon to be used for the notification small icon. The bitmap is decoded on the side of Trusted Web Activity client using the resource id from TrustedWebActivityService#getSmallIconId
.
Return | |
---|---|
Bitmap?: A Bitmap to be used for the small icon. |
Exceptions | |
---|---|
SecurityException |
If verification with the TrustedWebActivityService fails. |
getSmallIconId
open fun getSmallIconId(): Int
Requests an Android resource id to be used for the notification small icon.
Return | |
---|---|
Int: An Android resource id for the notification small icon. -1 if non found. |
Exceptions | |
---|---|
SecurityException |
If verification with the TrustedWebActivityService fails. |
notify
open fun notify(@NonNull platformTag: String, platformId: Int, @NonNull notification: Notification, @NonNull channel: String): Boolean
Requests a notification be shown.
Parameters | |
---|---|
platformTag |
String: The tag to identify the notification. |
platformId |
String: The id to identify the notification. |
notification |
String: The notification. |
channel |
String: The name of the channel in the Trusted Web Activity client app to display the notification on. |
Return | |
---|---|
Boolean: Whether notifications or the notification channel are blocked for the client app. |
Exceptions | |
---|---|
SecurityException |
If verification with the TrustedWebActivityService fails. |