Search code examples
node.jsgoogle-cloud-functionsapple-push-notificationsgoogle-cloud-messaging

Playing custom notification sound using Cloud Functions - iOS


I'm sending notification to my client app using Cloud Functions and GoogleCloudMessaging in this way:

const notificationContent = {
          notification: {
            title: `${senderName} has sent you a message`,
            body: `${messageString}`,
            icon: "default",
            sound: "customNotificationSound",
          },
        };
        return admin.messaging()
            .sendToDevice(notifToken, notificationContent)
            .then((result) =>{
              console.log("write done correctly");
            });

I want to use a custom notification sound instead of the default one; so I followed some guides online like this, this and this but they don't seem to answer my question.

Since I'm sending the push notification from the cloud function, do I still need to load the sound file in the client Main Bundle (I tried it and in fact it doesn't seem to work).

Or do I have to upload it somewhere else?

P.s. also the sound file extension is .wav so there shouldn't be problems for that matter.


Solution

  • I solved this and the answer is Yes, you still need to upload the music file in your main bundle even tough you're sending the push notification from cloud functions