标签: react-native-ios

如何在前台和后台接收本机推送通知

我正在使用 React Native Push Notification https://github.com/zo0r/react-native-push-notification 目前,它会在关闭应用程序后收到推送通知。

  1. 如何将我的 pushMessage(chat) 传递到通知中?

  2. 如何让它在前台(当应用程序仍然打开时)和后台(不打开应用程序)接收推送通知 *目前它会在关闭应用程序后收到通知

我应该在哪个部分工作?

App.js
--------
PushNotification.configure({
    // (required) Called when a remote or local notification is opened or received
    onNotification: function(notification) {
        console.log( 'NOTIFICATION:', notification );

        // process the notification . * this will overwrite the My Notification 1 below
        PushNotification.localNotification({
            foreground: true,
            title: "My Notification Title",
            message: "My Notification 2", // (required)
        });

        // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
        notification.finish(PushNotificationIOS.FetchResult.NoData);
    },


});


class App extends Component{ …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios react-native-push-notification

5
推荐指数
0
解决办法
4037
查看次数

如何一次全局设置自定义字体系列并在整个本机应用程序中使用而不调用每个“文本”组件?

根据此堆栈溢出解决方案,可以通过在每个Text组件中调用自定义字体来使用它。但是当我们Text的应用程序中有数千个组件时,我们可能会碰巧错过相同的字体系列。然后我们在字体系列的情况下失去一致性。

因此,有没有办法通过不调用每个Text组件来使用自定义字体系列?

react-native react-native-android react-native-ios

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

如何在ios stimulator中查看react-native创建的realm db

我想访问由我使用 react-native 创建的 ios 应用程序创建的领域数据库。它更容易adb pull用于 android 但对于 ios 我不太了解。有一些链接,如 -

  1. ios 应用程序中的领域文件
  2. 为上述链接查找应用程序 uuid

所以任何帮助,如何查看领域数据库以开发和调试 react-native 开发的 ios 应用程序。

感谢您的回答,但额外的(出于好奇)问题 - 但如何找到通过 react native 在 ios 模拟器上安装的应用程序 uid ?

realm react-native react-native-ios realm-mobile-platform

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

如何在 React Native 中备份/恢复 SQLite 数据库

我正在使用andpor/react-native-sqlite-storage在 React Native 中管理 SQLite 数据库。现在我想将我的所有数据库备份到一个加密文件中,然后在以后恢复它。我知道如何在 android 中做到这一点,但不知道如何在 react native 中实现这一点。

如果它在android中,下面的代码可以帮助我在不加密的情况下备份数据库。

 final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);

String outFileName = Environment.getExternalStorageDirectory()+"/database_copy.db";

// Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);

// Transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
    output.write(buffer, 0, length);
}

// Close the streams
output.flush();
output.close();
fis.close();
Run Code Online (Sandbox Code Playgroud)

所以我的问题是如何在 React …

sqlite react-native react-native-android react-native-ios

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

反应原生相机 - 默认预览似乎在 IOS 上放大

我正在为我的应用程序使用 React Native Camera,但我遇到了一个奇怪的问题。

这是我的代码:

<View flex>
    <RNCamera ref={ref=> { this.camera = ref; }} style={{flex : 1}} type={this.state.cameraType} flashMode={RNCamera.Constants.FlashMode.on} permissionDialogTitle={'Autorisation de l\'appareil photo'} permissionDialogMessage={'Nous avons besoin de votre permission pour accéder à l\'appareil photo.'} zoom={0} ratio={'16:9'} focusDepth={0} />
    <View style={{ position: 'absolute', width: 75, height: 75, top: this.state.currentHeight / 2.2, bottom: 0, right: 37, zIndex: 1 }}>
        <TouchableOpacity centerH onPress={this.takePicture.bind(this)}>
            <Image style={{ width: 75, height: 75 }} source={{ uri: "cameraButton" }} />
        </TouchableOpacity>
    </View>
    <View style={{ position: 'absolute', width: 50, …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-ios

5
推荐指数
0
解决办法
496
查看次数

说请将方法附加到此组件

我是本机反应的新手,我正在尝试向我的 API 发送一些数据,基本上是一个 POST 请求,添加了一个按钮并尝试使用它来调用获取请求,但我不确定我做错了什么这个 ??它在日志中显示“请将方法附加到此组件”,如果我在这方面做错了什么,请告诉我?

这是我的按钮

<Button
        style={{height: 60,width:150}}
        onClick={ () => this.submitNewCustomer()}
        title="SUBMIT"
        backgroundColor='#C0C0C0'
        color="black"
        />
Run Code Online (Sandbox Code Playgroud)

这是我的方法

submitNewCustomer(){
fetch('http://endpoint.net/api/customerdetail', {
  method: 'POST',
  headers: new Headers({
            'Content-Type': 'application/json', // <-- Specifying the Content-Type
    }),
  body: JSON.stringify({
    CustomerId: '1ef87a90-a941-4ebb-b101-66f74ac07778',
    CustomerName: this.state.customername,
    UserId:'user2',
    VehicleCompanyName:this.state.vehiclecompanyname,
    VehicleModelType:this.state.vehiclemodeltype,
    VehicleNumber:this.state.vehiclenumber,
    CustomerImage:'',
    Location:'',
    CustomerImageType:'png'
  }), // <-- Post parameters
})
.then((response) => response.text())
.then((responseText) => {
  alert(responseText);
})
.catch((error) => {
    console.error(error);
});

}
Run Code Online (Sandbox Code Playgroud)

任何输入都会非常有帮助

fetch react-native react-native-android react-native-ios

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

React Native TextInput 不会以正确的内容长度增加高度

我正在尝试使用 react native 元素和 react native 实现多行扩展文本输入,但我似乎无法让它正常运行。该行为显示在以下屏幕截图中:

正如你在这里看到的,文本有明显不止一行,但文本输入并没有展开。

在此处输入图片说明

每当我输入更多字符时,它都会扩展一点,但会向下扩展到键盘中。

在此处输入图片说明

添加另一行不会扩展键盘:

在此处输入图片说明

直到我添加更多字符,直到最新行是文本输入宽度的一半,输入才会展开

在此处输入图片说明

这是我用于文本输入的代码:

<View style={{flexDirection:'row', backgroundColor: 'transparent', height: Math.max(45, this.state.viewHeight)}}>
<Input
          containerStyle={{marginVertical: 0, width:300, marginLeft: 10}}
          inputStyle={[styles.textInput, {height: Math.max(35, this.state.height)}]}
          multiline
          enablesReturnKeyAutomatically={true}
          keyboardAppearance="dark"
          placeholder=""          
          onContentSizeChange={(event) => {
            if (this.state.height <= (35*6)){
            this.setState({
               height: event.nativeEvent.contentSize.height,
              viewHeight: event.nativeEvent.contentSize.height })
            }
          }}
          onChangeText={(message) => { this.setState({message})
        }}
Run Code Online (Sandbox Code Playgroud)

这是我的文本输入样式的代码:

textInput: {
      paddingHorizontal: 12,
      width: 100,
      backgroundColor: '#F0F0F0',
      borderStyle: 'solid',
      marginLeft: -4,
      overflow: 'hidden',
      marginTop: 5,
      borderWidth: 1,
      borderColor: 'lightgrey',
      borderRadius: 25,
    },
Run Code Online (Sandbox Code Playgroud)

似乎内容大小更改事件在错误的时间触发,有什么方法可以将其设置为仅在新行具有特定长度并向上扩展而不是向下扩展到键盘时触发?

javascript textinput react-native react-native-ios

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

在 UIManager 中找不到 RNTMap

我正在关注官方文档,复制并粘贴那里提供的代码:

https://facebook.github.io/react-native/docs/0.56/native-components-ios

但我仍然遇到这个错误 截屏

有谁知道文档缺少什么才能使其正常工作?

react-native react-native-ios

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

使用 react-native-gesture-handler 将触摸事件传递给子视图

我正在使用这个React-Native-Gesture-Handler来处理我的手势用户在应用程序上所做的。

但是手势似乎没有按预期工作,或者某些功能似乎无法将手势事件传递给子视图

这里的传承

              <PanGestureHandler
            {...this.props}
            ref={this.panRef}
            onGestureEvent={this._onGestureEvent}
            onHandlerStateChange={this._onPanHandlerStateChange}>
            <Animated.View
                onLayout={this._onLayout}
                style={[this.props.style,
                this.props.windowSize,
                this.props.isFullScreen ? {} : {
                    transform: [
                        { translateX: this._translateX },
                        { translateY: this._translateY },
                    ],
               }]}>
                    <View style={styles.wrapper}>       ----> Child View
                        {this.props.children}
                    </View>
            </Animated.View>
        </PanGestureHandler>
Run Code Online (Sandbox Code Playgroud)

在这个例子中,整个视图被一个平移手势包裹着,这个平移手势用于在屏幕空间周围移动视图。

除了这个子视图之外,这里还将包含将具有一些平移手势实现的视图。如果此平移手势事件由于外部平移手势而被取消。

有没有办法正确获取内部子视图的平移手势事件?

我无法找到任何解决方案来将这些父手势事件传递给孩子并取消父手势操作。

如果您需要有关整个问题的更多信息......请询问。

gesture react-native react-native-android react-native-ios

5
推荐指数
0
解决办法
1064
查看次数

视频的背景音频 react-native-video

我无法让 react-native-video 在后台播放 mp4 文件,它会播放 mp3 和音频文件,但拒绝继续播放视频。我已将 xcode 中的背景模式设置为打开,并选择了音频、播放和画中画,并传入了这些道具

playInBackground={true}
playWhenInactive={true}
ignoreSilentSwitch={'ignore'}
Run Code Online (Sandbox Code Playgroud)

当它是视频而不仅仅是音频时是否需要额外的配置?

react-native react-native-ios react-native-video

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