Giter Site home page Giter Site logo

Comments (5)

helenaford avatar helenaford commented on August 21, 2024 1

Hi, for iOS the system sound should work, in the docs there's an example setting the sound using a ringtone name (https://notifee.app/react-native/docs/ios/behaviour#sound). It may be the case that we only support ringtone sounds and not alert tones which is what those sounds in your screenshot are. But it could be a possible feature enhancement we can support.

As of Android, I'll get back to you on that one. I don't think we currently support system sounds (https://notifee.app/react-native/docs/android/behaviour#sound) but there might be a way we can use the url returned from the library.

from notifee.

helenaford avatar helenaford commented on August 21, 2024 1

Hi, I've taken a look at Android, and you can set the sound on the channel to the content url the library gives you (see doc update: https://notifee.app/react-native/docs/android/behaviour#device-sound)
For example:

await notifee.createChannel({
       id: "custom-sound",
       name: "Customer Sound",
       sound: soundsList[2].url, 
     });
     
     await notifee.displayNotification({
      ...
       android: {
         channelId: "custom-sound",
       },
     });

from notifee.

helenaford avatar helenaford commented on August 21, 2024 1

Update on iOS sounds, there was an issue with the docs. As it stands, the sound has to be inside your app bundle for iOS to play the sound. See https://developer.apple.com/documentation/usernotifications/unnotificationsound?language=objc

There may be a workaround where we can play the system sound at the same time the notification is displayed, this will need some testing to make sure the sound plays at the same time the notification is displayed. But, this will only work for notifications shown via displayNotification and trigger notifications :(

from notifee.

helenaford avatar helenaford commented on August 21, 2024

Closing as the question has been answered above.

from notifee.

shirodkarpushkar avatar shirodkarpushkar commented on August 21, 2024

Hi, I've taken a look at Android, and you can set the sound on the channel to the content url the library gives you (see doc update: https://notifee.app/react-native/docs/android/behaviour#device-sound) For example:

await notifee.createChannel({
       id: "custom-sound",
       name: "Customer Sound",
       sound: soundsList[2].url, 
     });
     
     await notifee.displayNotification({
      ...
       android: {
         channelId: "custom-sound",
       },
     });

This worked for android with s3 URLs
For iOS I am using '@react-native-community/audio-toolkit' package in the background and playing sound before displaying the notification.

import { Player } from '@react-native-community/audio-toolkit';

const sound = new Player(soundFile.file_path);
sound.play();
await notifee.displayNotification(notifeeObj);

from notifee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.