0

I'm having issue that notifications sounds doesn't play, specially for critical notifications i'm using react native.

i already have entitlement and approval from apple i have the sound file .wav 3 seconds length in the root folder of the ios project i receive the critical notifications but the sound doesn't play i receive the regular notifications just fine

i followed all instructions to implement onesignal into the app and it's working perfectly fine, the only issue is the sound not playing

this is the service file i updated it to force the volume on but still no luck.

    import UserNotifications
import OneSignalExtension

class NotificationService: UNNotificationServiceExtension {
    var contentHandler: ((UNNotificationContent) -> Void)?
    var receivedRequest: UNNotificationRequest!
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest,
                             withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {

        self.receivedRequest = request
        self.contentHandler = contentHandler
        self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

        guard let bestAttemptContent = bestAttemptContent else {
            contentHandler(request.content)
            return
        }

        // Pass through OneSignal
        OneSignalExtension.didReceiveNotificationExtensionRequest(
            self.receivedRequest,
            with: bestAttemptContent,
            withContentHandler: self.contentHandler
        )

        // ---- SAME AS OLD PROJECT ----
        // If payload contains CRITICAL = YES → Force iOS critical sound
        if let critical = request.content.userInfo["CRITICAL"] as? String,
           critical.uppercased() == "YES" {

            bestAttemptContent.sound =
                UNNotificationSound.defaultCriticalSound(withAudioVolume: 1.0)
        }

        contentHandler(bestAttemptContent)
    }

    override func serviceExtensionTimeWillExpire() {
        if let contentHandler = contentHandler,
           let bestAttemptContent = bestAttemptContent {

            OneSignalExtension.serviceExtensionTimeWillExpireRequest(
                self.receivedRequest,
                with: self.bestAttemptContent
            )
            contentHandler(bestAttemptContent)
        }
    }
}

Here is my directory structure

directory structure

am i missing something ?

i tried this solution Here and nothing worked

5
  • can you post json of push that you receive... Commented Nov 18 at 10:31
  • Have you added the sound to a Target? Commented Nov 18 at 11:04
  • @Thomasino73 Yes sound is in target and i removed it and added it back again. Commented Nov 18 at 19:06
  • @FahimParkar i tried multiple times i couldn't get the log :( Commented Nov 18 at 19:10
  • however i tried on different device iPhone 12 iOS 17.4 and the sound triggered, but not on iPhone 16Pro iOS 26.0.1 Commented Nov 18 at 19:12

1 Answer 1

2

My code and everything was 100% the issue was in the iOS 26

iOS 26 has issues with notifications sounds and had to restart the real phone and push it into ringing mode and silent mode in order for the notifications sounds to work correctly.

i realized that after i tested the app on iPhone with iOS 17.4 and the sounds worked immediately.

Sign up to request clarification or add additional context in comments.

1 Comment

Glad to hear you got it working!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.