XMTP Messenger SDK
MessengerSDK
Android library for communicating with the XMTP Messenger app via AIDL IPC. Wraps service binding, threading, and permissions into a clean coroutine-based Kotlin API.
Installation
Step 1. Add the JitPack repository to your project's settings.gradle.kts (inside the dependencyResolutionManagement block):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}If your project uses a root
build.gradle.ktswithallprojects { repositories { ... } }instead, add the maven line there.
Step 2. Add the dependency to your app module's build.gradle.kts:
dependencies {
implementation("com.github.EthereumPhone:MessengerSDK:0.2.0")
}Quick Start
Permissions
Only the MessagingClient (send as user) requires a runtime permission. The IdentityClient (isolated identity) is permission-free — any app can bind and create its own identity.
SEND_MESSAGE_AS_USER
MessagingClient
Send messages as the Messenger's logged-in user
Check and request the permission:
API
MessengerSDK
getInstance(context)
Get singleton instance (throws if Messenger not installed)
messaging
MessagingClient for sending as the logged-in user
identity
IdentityClient for isolated identity operations
unbindAll()
Unbind all services
MessagingClient
bind() / unbind()
Bind/unbind the messaging service
awaitConnected()
Suspend until connected
connectionState
StateFlow<ConnectionState>
sendMessage(address, body)
Send a DM, returns message ID
sendGroupMessage(conversationId, body)
Send to a conversation, returns message ID
isClientReady()
Check if XMTP client is ready
getUserAddress()
Get the logged-in user's address
getInboxId()
Get the logged-in user's inbox ID
IdentityClient
bind() / unbind()
Bind/unbind the identity service
awaitConnected()
Suspend until connected
connectionState
StateFlow<ConnectionState>
createIdentity()
Create or retrieve an isolated identity
hasIdentity()
Check if an identity exists
getIdentityAddress()
Get the isolated identity's address
getInboxId()
Get the isolated identity's inbox ID
sendMessage(address, body)
Send from the isolated identity
Error Handling
All SDK exceptions extend SdkException:
MessengerNotInstalledException- Messenger app not foundPermissionNotGrantedException- Required permission not grantedServiceNotConnectedException- Service not bound (callbind()first)RemoteCallException- IPC call failed
Requirements
Android API 28+
XMTP Messenger app installed on the device
Gihub Repo Below:
Last updated