简体   繁体   English

Alert.alert 在 react-native 中自动触发两次

[英]Alert.alert triggerd twice automatically in react-native

Alert triggerd automatically twice.警报自动触发两次。 but if i comment Alert and only write console.warn() then it not triggered twice.但是如果我评论 Alert 并且只写 console.warn() 那么它不会触发两次。 but Alert triggered twice.但是 Alert 触发了两次。

componentDidMount(){
          this._notificationSubscription = Expo.Notifications.addListener(
                this._handleNotification
              );
        }
          
        _handleNotification(notification){
            if (notification.data) {
            console.warn('inside if block')
            Alert.alert(
              "push notification",
              [
                { text: "Cancel" },
                {
                  text: "Ok",
                  onPress: () => this.props.navigation.navigate("More"),
                },
              ],
              { cancelable: false }
            ); 
          }
    }

expo sdk :- 39博览会 SDK :- 39

Call this way这样打电话

_handleNotification = (notification) => {
    ....
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM