0

I encountered a problem with PushNotificationIOS using React Native. After I updated RN from 0.48 to 0.54 and upgraded my iPhone with iOS 11.3, my iOS app can receive push message but without sound. The notification part of the code was left untouched and there was no problem with message sound. Just wonder what configuration might need to be made to make the message sound normal. Thanks for your suggestions.

I check the notification object in debugging mode and it got alert title, body, and should value and looks good.

    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]));
        }
      }
Kiran Sarvaiya
  • 1,318
  • 1
  • 13
  • 37

1 Answers1

-1

How to make sound when notification came if application is active in ios?

Just found out that forcing to play the sound event if the app is at foreground is possible. Just call the API to play the sound/do vibration.