title: Playing a custom sound on receiving a remote push notification on iOS 12 from FCM
body: <p>I am trying to get a custom sound to play when a <strong>REMOTE</strong> notification is received while the app is either closed completely or in the background, but everything that I have tried has not worked.</p>
  
  <p>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. </p>
  
  <p>Here is a screenshot of my XCode project manager, showing where my custom sound is located. <a href="https://i.stack.imgur.com/BFNzU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BFNzU.png" alt="BundleScreenshot"></a></p>
  
  <p>The code that sends a Remote Notification from a firebase function:</p>
  
  <pre><code>userData.tokens.forEach(async token =&gt; {
      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);
  });
  </code></pre>
  
  <p>Here is what my register code looks like within my AppDelegate:</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>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.</p>
  
  <p>Thanks for any suggestions.</p>
  
  <p><strong>EDIT</strong>
  Just forgot, I have this in my info.plist file as well</p>
  
  <pre><code>&lt;key&gt;UILocalNotificationDefaultSoundName&lt;/key&gt;
      &lt;string&gt;OnceAgainNotification.caf&lt;/string&gt;  
  </code></pre>