Customizing the Notification
Since the SORI SDK provides a foreground service, the SDK contains a default notification that is displayed when the service is running. However, you can customize this notification to better suit your app's branding and user experience.
To customize the notification, you can use the startRecognition
method of the SORIAudioRecognizer
class. This method allows you to specify a custom title, body, and icon for the notification.
val audioRecognizer = SORIAudioRecognizer()
// ...
audioRecognizer.startRecognition(
this,
title = "Custom Title",
body = "Custom Body",
icon = R.drawable.custom_icon
)
SORIAudioRecognizer audioRecognizer = new SORIAudioRecognizer();
// ...
audioRecognizer.startRecognition(
this,
"Custom Title",
"Custom Body",
R.drawable.custom_icon
);
If you want to more control over the notification, you can implement SORIAudioRecognizer.NotificationProvider
to SORIAudioRecognizer
class. This allows you to build a custom notification using the NotificationCompat.Builder
class. Please implement the build
method of the NotificationProvider
interface to create your custom notification.
val notificationProvider = object : SORIAudioRecognizer.NotificationProvider {
override fun build(builder: NotificationCompat.Builder): Notification {
return builder
.setContentTitle("Custom Title")
.setContentText("Custom Body")
.setSmallIcon(R.drawable.custom_icon)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
// Add any other customizations you want
}
}
SORIAudioRecognizer.notificationProvider = notificationProvider