Hello !
I have a cloud function using python to send notifications. However, I couldn't succeed in setting a custom notification sound. Could you help me to find how to do so please?
Bellow is the code used to send the notification. The function "send_notif" is called by another function which is triggered via an HTTP POST request with the device token and the sound's path as data.
My sound path is "/data/user/0/com.testapp.androidapp/files/ReactNativeBlobUtilTmp_sg3l30ks8u9afgmxy5i8k" as I use the no-code appGyver tool to build my app. However, maybe I could write the path to a Google Cloud Storage ou firestore?
My function code:
def send_notif(
device_token, notif_body: str, sound_path: str, notif_title: str = "notifTtl cloud"
):
# See documentation on defining a message payload.
notif = messaging.Notification(title=notif_title, body=notif_body)
android_notif = messaging.AndroidNotification(sound=sound_path, default_sound=False)
message = messaging.Message(
notification=notif,
token=device_token,
android=messaging.AndroidConfig(notification=android_notif),
)
response = messaging.send(message)
return f"Successfully sent message: {response}"
Hi, Manuel,
I think you are missing the extension file (.ie: .wav or .mp3)
My sound path is "/data/user/0/com.testapp.androidapp/files/ReactNativeBlobUtilTmp_sg3l30ks8u9afgmxy5i8k"...