Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React Native PushNotification IOS可以接收推送消息,但没有声音_Ios_React Native_Push Notification - Fatal编程技术网

React Native PushNotification IOS可以接收推送消息,但没有声音

React Native PushNotification IOS可以接收推送消息,但没有声音,ios,react-native,push-notification,Ios,React Native,Push Notification,我在使用React Native时遇到了PushNotificationIOS问题。在我将RN从0.48更新到0.54并用iOS 11.3升级我的iPhone之后,我的iOS应用程序可以接收推送消息,但没有声音。代码的通知部分保持不变,消息声音没有问题。只是想知道需要进行什么配置才能使消息听起来正常。谢谢你的建议 我在调试模式下检查了notification对象,它得到了警报标题、主体和值,看起来不错 componentWillMount() { PushNotifica

我在使用React Native时遇到了PushNotificationIOS问题。在我将RN从0.48更新到0.54并用iOS 11.3升级我的iPhone之后,我的iOS应用程序可以接收推送消息,但没有声音。代码的通知部分保持不变,消息声音没有问题。只是想知道需要进行什么配置才能使消息听起来正常。谢谢你的建议

我在调试模式下检查了notification对象,它得到了警报标题、主体和值,看起来不错

    componentWillMount() {
        PushNotificationIOS.addEventListener("register", this._onRegistered);
        PushNotificationIOS.addEventListener(
          "registrationError",
          this._onRegistrationError
        );
        PushNotificationIOS.addEventListener(
          "notification",
          this._onRemoteNotification
        );
        PushNotificationIOS.addEventListener(
          "localNotification",
          this._onLocalNotification
        );
      }
    ....

    _onRegistered(deviceToken) {
       if (deviceToken)
...
        console.log("Registered deviceToken=" + deviceToken);
      }

    _onRemoteNotification(notification) {
        notification.finish(PushNotificationIOS.FetchResult.NoData);
        var body = notification.getMessage().body.split("|");
        if (body.length === 1)
          Warn(
            notification.getMessage().title, //message only.
            body[0],
            [{ text: "OK", onPress: null }]
          );
        else if (body.length === 2) {
          //code + message
          Warn(notification.getMessage().title, body[0] + "\n" + body[1], [
            { text: "OK", onPress: null }
          ]);
          store.dispatch(sessionActionCreators.updateConfirmCode(body[0]));
        }
      }

刚刚发现,如果应用程序位于前台,则可以强制播放声音事件。只需调用API来播放声音/进行振动