当应用程序未在 React-Native firebase 中运行时,如何设置通知声音

new*_*eep 6 push-notification ios firebase react-native react-native-firebase

我试图在应用程序未在 IOS 中运行时让通知响起。

这是我的代码。

  this.notificationListener = firebase.notifications().onNotification((notification: Notification) => {

    // SET SYSTEM DEFAULT SOUND!
    notification.setSound("default");
    firebase.notifications().displayNotification(notification);

  });
Run Code Online (Sandbox Code Playgroud)

当应用程序处于后台或前台时(也许我可以说“应用程序正在运行”),通知会响起。

我应该使用其他监听器吗?或者我应该添加自己的铃声文件吗?

new*_*eep 4

最后,我知道该怎么做。这个问题与react-native-firebase无关,它与我的服务器有关。

当服务器向应用程序发布消息时,服务器可以设置多个选项,例如声音、徽章。

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

如果您将声音部分设置为“默认”,即使您的应用程序处于后台,您也可以在收到通知时获得默认通知声音。

希望我的回答可以帮助到像我这样的react-native-firebase初学者。