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
am i missing something ?
i tried this solution Here and nothing worked
