Push Notifications ᴺᴱᵂ
The OpenWeb Android SDK delivers push notifications for user interactions such as comment replies and mentions. Configure notification behaviour through OWNotificationsCustomizations, available on OpenWeb.manager.ui.customizations.notifications. When the user taps a notification, extract its routing data with OpenWeb.manager.helpers.getRoutingData(intent) and forward it to OWUIComponents.openConversation() to deep-link the user to the right place.
Requirements
- Android API 26 or higher for custom notification sounds (notification channels are created at API 26+)
POST_NOTIFICATIONSpermission declared in your manifest and runtime-granted on API 33+OpenWeb.manager.spotIdassigned before the first notification is received
Declare the Permission
Add the POST_NOTIFICATIONS permission to your app's AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application ...>
...
</application>
</manifest>On API 33+ (Android 13), request the permission at runtime before the first notification is posted.
Configure the Tap Intent
Set the Intent the SDK launches when a user taps a notification. Assign it before setting OpenWeb.manager.spotId.
val tapIntent = Intent(context, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
}
OpenWeb.manager.ui.customizations.notifications.tapIntent = tapIntentNote: If tapIntent is null, the SDK does not launch any activity on notification tap.
Configure a Custom Sound
Assign a custom sound Uri before the SDK creates its notification channel.
val soundUri = Uri.parse(
ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + context.packageName + "/raw/notification_sound"
)
OpenWeb.manager.ui.customizations.notifications.sound = soundUriImportant: Notification channel settings — including sound — are locked at channel creation time and cannot be changed afterward. Assign sound before you set OpenWeb.manager.spotId, or the custom sound will be ignored and a developer warning is logged.
Handle Notification Routing
When the user taps a notification, the SDK launches your tapIntent carrying routing information for the conversation, comment thread, or other entry point the notification refers to. Extract it with OpenWeb.manager.helpers.getRoutingData(intent) and forward it into OWUIComponents.openConversation().
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleNotificationIntent(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleNotificationIntent(intent)
}
private fun handleNotificationIntent(intent: Intent) {
val routingData = OpenWeb.manager.helpers.getRoutingData(intent) ?: return
OpenWeb.manager.ui.components.openConversation(
postId = routingData.postId,
route = routingData.route
)
}
}getRoutingData returns null if the intent did not originate from an OpenWeb notification.
Embed as a Fragment
openConversation() launches the conversation as a full-screen, SDK-managed activity. If you'd rather host the conversation inside your own screen — for example, in a tab, a side panel, or above your own toolbar — call OWUIComponents.getConversation() instead. It returns a Fragment you can place anywhere in your layout.
private fun handleNotificationIntent(intent: Intent) {
val routingData = OpenWeb.manager.helpers.getRoutingData(intent) ?: return
OpenWeb.manager.ui.components.getConversation(
postId = routingData.postId,
route = routingData.route,
completion = object : SpotCallback<Fragment>() {
override fun onSuccess(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.container, fragment)
.commit()
}
override fun onFailure(exception: SpotException) {
// handle error
}
}
)
}OWRoutingData
| Property | Purpose |
|---|---|
postId | Post identifier associated with the notification. (String) |
route | The conversation entry point to navigate to. (OWConversationRoute) |
Possible Routes
The route returned in OWRoutingData is an OWConversationRoute. The SDK delivers one of the following subclasses depending on the notification payload:
| Route | Opens |
|---|---|
OWConversationRoute.OWCommentThreadRoute(commentId) | The conversation scrolled to a specific comment thread. |
OWConversationRoute.OWCommentCreationRoute(type) | The comment editor (reply or new comment). |
Forwarding the route directly into openConversation() (as shown above) handles all cases — no manual when branch is required.
See Components for the full openConversation() signature and additional parameters such as articleSettings, additionalSettings, and actionCallbacks.
