I am trying to get a custom sound to play when a REMOTE notification is received while the app is either closed completely or in the background, but everything that I have tried has not worked.
The Audio file that I am using is a .caf file which is supported, it is 20 seconds long which is within apple's limits. The file is located in the main app bundle, not within a specific scheme. and my register for remote notifications is registered with .Sound.
Here is a screenshot of my XCode project manager, showing where my custom sound is located.
The code that sends a Remote Notification from a firebase function:
userData.tokens.forEach(async token => {
console.log("Token: "+token);
const message = {
data: {
type: "type"
},
android: {
priority: "high"
},
notification: {
"title": "Title of message",
"sound": "customSound.caf"
},
apns: {
headers: {
"apns-priority": "10"
},
payload: {
aps: {
sound: "customSound.caf"
},
sound: "customSound.caf"
}
},
token: token
};
console.log(message);
await admin.messaging().send(message);
});
Here is what my register code looks like within my AppDelegate:
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
I have even tried rebooting my device because that was a bug that I read about on another Stack Overflow but that didn't do anything. If it helps I am running iOS 12.1.4 on a 6th generation iPad.
Thanks for any suggestions.
EDIT Just forgot, I have this in my info.plist file as well
<key>UILocalNotificationDefaultSoundName</key>
<string>OnceAgainNotification.caf</string>