A powerful Android SDK for real-time communication, enabling seamless push messages and real-time interactions in your Android applications.
- Real-time bidirectional streaming
- User targeting with IDs, tags, and metadata
- Customizable push messages with dynamic templates
- Automatic connection management
- Support for experiments and A/B testing
- Android 6.0 (API level 24) and above
- Java 11 or Kotlin 1.5+
- Gradle 7.4 or later
Get started with Pushlytic in your Android app - it's quick and easy!
The Pushlytic Android SDK is published on Maven Central. You can add it to your project using Gradle or Maven.
- Add the Pushlytic Android SDK dependency to your
build.gradlefile:dependencies { implementation("com.pushlytic:sdk:0.1.4") } - Sync your project with Gradle files.
Note: We're rapidly improving Pushlytic! 🚀 During our pre-1.0 phase:
- Minor version updates (0.x.0) may include exciting new features and improvements that could have breaking changes.
- Using "Up to Next Minor" ensures you get all bug fixes while maintaining stability.
- Once we hit 1.0.0, we'll follow strict semantic versioning with "Up to Next Major Version."
Join us early and help shape the future of push infrastructure! Your feedback and use cases are invaluable as we move toward our 1.0.0 release.
-
Configure the SDK in your
Applicationclass:import android.app.Application import com.pushlytic.sdk.Pushlytic class YourApplication : Application() { override fun onCreate() { super.onCreate() // Configure the SDK with your API key Pushlytic.configure( this, Pushlytic.Configuration(apiKey = "YOUR_API_KEY") ) } }
-
Set up a
PushlyticListenerto handle connection status and messages:Pushlytic.setListener(object : PushlyticListener { override fun onConnectionStatusChanged(status: ConnectionStatus) { println("Pushlytic Status: $status") } override fun onMessageReceived(message: String) { println("Pushlytic Message: $message") } })
Open a connection to start receiving messages:
// Open a message stream
Pushlytic.openMessageStream()
// Later, when you want to stop receiving messages:
// - Set clearState to false to allow automatic reconnection on app foreground
// - Set clearState to true to clear all connection metadata and prevent automatic reconnection
Pushlytic.endStream(clearState = false)Register user data such as user ID, tags, and metadata:
// Register user ID
Pushlytic.registerUserID("unique_user_id")
// Add tags for targeting
Pushlytic.registerTags(listOf("premium_user", "electronics"))
// Set user metadata
Pushlytic.setMetadata(
mapOf(
"first_name" to "John",
"account_type" to "premium"
)
)To receive real-time updates from the SDK, implement PushlyticListener and handle connection statuses and incoming messages:
// Define message types
data class CustomMessage(val id: String, val content: String)
Pushlytic.setListener(object : PushlyticListener {
override fun onConnectionStatusChanged(status: ConnectionStatus) {
println("Connection status: $status")
}
override fun onMessageReceived(message: String) {
Pushlytic.parseMessage(
message,
CustomMessage::class.java,
completion = { parsedMessage ->
println("Received message: ${parsedMessage.content}")
},
errorHandler = { error ->
println("Error parsing message: ${error.message}")
}
)
}
})Send custom analytics events:
Pushlytic.sendCustomEvent(
name = "purchase",
metadata = mapOf("item_id" to "12345", "price" to 19.99)
)An example app demonstrating usage of Pushlytic SDK features is available in the example/ directory. It showcases:
- Stream connection
- Message handling
- User segmentation
- Metadata-driven personalization
- sdk/: Core SDK functionality
- example/: Fully functional example app demonstrating SDK usage
- tests/: Unit tests for SDK components
Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines on submitting issues, feature requests, and pull requests.
Pushlytic Android SDK is available under the MIT License. See the LICENSE file for more information.
- For security vulnerabilities, contact our security team at security@pushlytic.com
- For general support, reach out to support@pushlytic.com or visit our documentation site