PostMessageServiceConnection

abstract class PostMessageServiceConnection : ServiceConnection
kotlin.Any
   ↳ androidx.browser.customtabs.PostMessageServiceConnection

A ServiceConnection for Custom Tabs providers to use while connecting to a PostMessageService on the client side.

Summary

Public constructors

Public methods
open Boolean
bindSessionToPostMessageService(context: Context!, packageName: String!)

Binds the browser side to the client app through the given PostMessageService name.

Boolean
postMessage(message: String!, extras: Bundle!)

Posts a message to the client.

Unit

Unit

Boolean

Notifies the client that the postMessage channel requested with CustomTabsService#requestPostMessageChannel( * CustomTabsSessionToken, android.net.Uri) is ready.

open Unit

Unbinds this service connection from the given context.

open Unit

Called when the PostMessageService connection is established.

open Unit

Called when the connection is lost with the PostMessageService.

Public constructors

<init>

PostMessageServiceConnection(session: CustomTabsSessionToken!)

Public methods

bindSessionToPostMessageService

open fun bindSessionToPostMessageService(context: Context!, packageName: String!): Boolean

Binds the browser side to the client app through the given PostMessageService name. After this, this PostMessageServiceConnection can be used for sending postMessage related communication back to the client.

Parameters
context Context!: A context to bind to the service.
packageName Context!: The name of the package to be bound to.
Return
Boolean: Whether the binding was successful.

postMessage

fun postMessage(message: String!, extras: Bundle!): Boolean

Posts a message to the client. This should be called when a tab controlled by related CustomTabsSession has sent a postMessage. If postMessage() is called from a single thread, then the messages will be posted in the same order.

Parameters
message String!: The message sent.
extras String!: Reserved for future use.
Return
Boolean: Whether the postMessage was sent to the remote successfully.

onServiceDisconnected

fun onServiceDisconnected(name: ComponentName!): Unit

onServiceConnected

fun onServiceConnected(name: ComponentName!, service: IBinder!): Unit

notifyMessageChannelReady

fun notifyMessageChannelReady(extras: Bundle!): Boolean

Notifies the client that the postMessage channel requested with CustomTabsService#requestPostMessageChannel( * CustomTabsSessionToken, android.net.Uri) is ready. This method should be called when the browser binds to the client side PostMessageService and also readies a connection to the web frame.

Parameters
extras Bundle!: Reserved for future use.
Return
Boolean: Whether the notification was sent to the remote successfully.

unbindFromContext

open fun unbindFromContext(context: Context!): Unit

Unbinds this service connection from the given context.

Parameters
context Context!: The context to be unbound from.

onPostMessageServiceConnected

open fun onPostMessageServiceConnected(): Unit

Called when the PostMessageService connection is established.

onPostMessageServiceDisconnected

open fun onPostMessageServiceDisconnected(): Unit

Called when the connection is lost with the PostMessageService.