Skip to content

Commit

Permalink
Register additional notification group/channel in example
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Mar 27, 2024
1 parent 2e19b2a commit e553d1c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/notifications/custom_notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ First you need to override the <code>getJobFromIntent</code> function in the imp
```kotlin,ignore
package com.example.application
import android.app.NotificationManager
import android.content.Intent
import breez_sdk_notification.ForegroundService
import breez_sdk_notification.job.Job
import breez_sdk_notification.Message
import breez_sdk_notification.NotificationHelper.Companion.createNotificationChannel
import breez_sdk_notification.NotificationHelper.Companion.createNotificationChannelGroup
import breez_sdk_notification.NotificationHelper.Companion.registerNotificationChannels
class ExampleForegroundService : ForegroundService() {
Expand All @@ -51,6 +54,20 @@ class ExampleForegroundService : ForegroundService() {
// First register the default notification channels
registerNotificationChannels(applicationContext, DEFAULT_CLICK_ACTION)
// Then register any additional notification channels
createNotificationChannelGroup(
applicationContext,
"custom_job_group",
"Custom Job Group",
"Required to handle custom job requests when the application is in the background"
)
createNotificationChannel(
applicationContext,
"CUSTOM_JOB",
"Custom Job",
"Notifications for custom job when the application is in the background",
"custom_job_group",
NotificationManager.IMPORTANCE_DEFAULT
)
}
// Override the `getJobFromIntent` function
Expand Down Expand Up @@ -181,8 +198,7 @@ class CustomJob(
// The `start` function is called once the SDK instance is connected
override fun start(breezSDK: BlockingBreezServices) {
// Remember if you are using a custom notification channel, you have to register it first
val applicationId = context.applicationContext.packageName
val notificationChannel = "${applicationId}.CUSTOM_JOB"
val notificationChannel = "CUSTOM_JOB"
try {
// Decode the `CustomRequest` from the payload
val request = Json.decodeFromString(CustomRequest.serializer(), payload)
Expand Down

0 comments on commit e553d1c

Please sign in to comment.