小编bas*_*tti的帖子

React Native IOS状态栏背景

由于将backgroundColor props应用于StatusBar组件,因此未在IOS上应用.我需要设置SafeAreaView的背景颜色以获得我想要的效果,它工作正常但在iPhone X上它将在屏幕底部具有相同的颜色.我该如何解决这个问题?

在此输入图像描述

statusbar ios react-native

7
推荐指数
1
解决办法
2806
查看次数

React Native在嵌套StackNavigator之间导航

我有三个导航器,登录完成后我导航到DashBoard屏幕,但是当我想从DashBoard屏幕注销时出现问题,this.props.navigation.navigate('Login')工作正常但是我想在按下注销按钮时清除堆栈.

const DashBoardStackNavigator = createStackNavigator({
      DashBoard: DashBoard,
      Second:Second,
      Third:Third
    })


const BottomTabNavigator = createBottomTabNavigator({
  DashBoardStackNavigator,
  Account,
  Report,
  Members
}})

const AppStackNavigator = createStackNavigator({
  Login: Login,
  BottomTabNavigator: BottomTabNavigator

})


export default createAppContainer(AppStackNavigator)
Run Code Online (Sandbox Code Playgroud)

我试了以下没有运气

const resetAction = StackActions.reset({
  index: 0,
  actions: [NavigationActions.navigate({ routeName: 'Login' })],
});
this.props.navigation.dispatch(resetAction);
Run Code Online (Sandbox Code Playgroud)

错误:没有为密钥登录定义路由,必须是DashBoard之一

navigation reactjs react-native react-navigation

7
推荐指数
1
解决办法
752
查看次数

使用 PHP 的 Expo 推送通知

我正在尝试使用 PHP 向我的 React Native 应用程序发送推送通知,下面的代码也发送了所有注册其令牌的用户,尽管令牌用于特定设备,但它会立即发送大量通知,但它不断将通知推送到全部

$key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
$title = "title";
$interestDetails = ['https://exp.host/--/api/v2/push/send',$key];

  try{

      $expo = \ExponentPhpSDK\Expo::normalSetup();

  // Subscribe the recipient to the server
      $expo->subscribe($interestDetails[0], $interestDetails[1]);

  // Build the notification data

    $notification = ['title' => $title,'body' => $msg];

  // Notify an interest with a notification
   $expo->notify($notification);

  $status = 'success';
}catch(Exception $e){



}


   ?>
Run Code Online (Sandbox Code Playgroud)

我尝试更改我的代码如下

<?php

$key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
$title = "title";


  try{

      $expo = \ExponentPhpSDK\Expo::normalSetup();



  // Build the notification data

  $notification = ['to' => $key,'title' => $title,'body' => …
Run Code Online (Sandbox Code Playgroud)

php notifications react-native expo

4
推荐指数
1
解决办法
5770
查看次数

从样式表反应本机访问状态

我正在尝试根据状态设置容器的背景,但它不断向我显示未定义错误bg

constructor(props) {
    super(props)
    this.state = {
        bg:'#fff'
    }
}

render(){
    return(<View style={styles.container} />)
} 

const styles = StyleSheet.create({
    container:{
        flex: 1,
        backgroundColor: this.state.bg,
    }
})
Run Code Online (Sandbox Code Playgroud)

react-native

3
推荐指数
1
解决办法
3044
查看次数

在注册问题上反应本机推送通知

我正在获取令牌,但无法将其设置为状态,也无法从 onRegister 方法调用任何函数

 PushNotification.configure({
        onRegister: function(token) {
           alert(token.token) //works fine
       //shows an error this setState is not a function
           this.setState({token:token.token})
      //shows an error this this.sendToken.. is not a function
           this.sendTokenTOServer(token.token) 

        }
    });
Run Code Online (Sandbox Code Playgroud)

push-notification react-native

1
推荐指数
1
解决办法
1336
查看次数