Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to add sound to notification #34

Closed
Supereuro opened this issue Jun 4, 2024 · 2 comments · Fixed by #61 or #62
Closed

Possibility to add sound to notification #34

Supereuro opened this issue Jun 4, 2024 · 2 comments · Fixed by #61 or #62
Labels
enhancement New feature or request

Comments

@Supereuro
Copy link

Is there a possibility you could enhance the notifier configuration to add (local)sound to notifications?

@mirzemehdi
Copy link
Owner

Yes this can be implemented in future. Or if you want you can also add and create PR for that :)

@mirzemehdi mirzemehdi added the enhancement New feature or request label Jun 5, 2024
This was linked to pull requests Aug 8, 2024
@mirzemehdi
Copy link
Owner

This is implemented in 1.2.1 version of kmpnotifier @Supereuro.

Add custom notification sound when initializing the library as below:

Android:

@param soundUri - Custom Notification sound, uri should be converted to String. Default value is null, if null default notification sound will be played. For custom notification sound put notification sound in res/raw directory. See how it is used in sample app: 3708ea8

val customNotificationSound =
        Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + "com.mmk.kmpnotifier.sample" + "/" + R.raw.custom_notification_sound)
    NotifierManager.initialize(
        configuration = NotificationPlatformConfiguration.Android(
            notificationIconResId = R.drawable.ic_launcher_foreground,
            showPushNotification = true,
            notificationChannelData = NotificationPlatformConfiguration.Android.NotificationChannelData(
                soundUri = customNotificationSound.toString()
            )
        )
    )

iOS:

@param notificationSoundName - Custom notification sound name. Default value is null. If set null, default notification sound will be played. For cusotm notification sound, place the file in the Resources directory of your iOS target. Ensure the file is added to your target's "Build Phases" under "Copy Bundle Resources". See how it is used in sample app: 4b2a90d

NotifierManager.initialize(
        NotificationPlatformConfiguration.Ios(
            showPushNotification = true,
            askNotificationPermissionOnStart = true,
            notificationSoundName = "custom_notification_sound.wav"
        )
    )

For more details please check: PR #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants