非常教程

React native参考手册

APIs

PermissionsAndroid

需要本机代码的项目

此API仅适用于react-native init使用Create React Native App创建的项目或使用Create React Native App创建的项目,该项目已经弹出。有关弹出的更多信息,请参阅创建React Native App存储库的指南。

PermissionsAndroid提供对Android M新的权限模型的访问。只要安装了应用程序,只要它们出现,默认情况下就会授予某些权限AndroidManifest.xml。但是,“危险”权限需要对话提示。您应该为这些权限使用此模块。

在SDK版本23之前的设备,如果他们出现在清单中的权限自动授予,所以checkrequest应始终是真实的。

如果用户先前已关闭了您提示的权限,则操作系统会建议您的应用程序显示需要该权限的基本原理。可选rationale参数仅在必要时才显示对话框提示 - 否则会出现正常的权限提示。

import { PermissionsAndroid } from 'react-native';

async function requestCameraPermission() {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.CAMERA,
      {
        'title': 'Cool Photo App Camera Permission',
        'message': 'Cool Photo App needs access to your camera ' +
                   'so you can take awesome pictures.'
      }
    )
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      console.log("You can use the camera")
    } else {
      console.log("Camera permission denied")
    }
  } catch (err) {
    console.warn(err)
  }
}

方法

constructor()

checkPermission(permission)

DEPRECATED - use check

返回解析为布尔值的promise,以确定是否已授予指定的权限

@deprecated

检查(许可)

返回解析为布尔值的promise,以确定是否已授予指定的权限

requestPermission(permission, rationale?)

DEPRECATED - 使用请求

提示用户启用权限并返回解析为布尔值的承诺,指示用户是允许还是拒绝该请求

如果包含可选的基本原理参数(这是带有titleand 的对象message),则此函数将与OS一起检查是否需要显示解释为什么需要权限的对话框(https://developer.android.com/training/ permissions / requests.html#explain),然后显示系统权限对话框

@deprecated

request(permission, rationale?)

提示用户启用权限并返回解析为指示用户是否允许或拒绝该请求的字符串值的承诺

如果包含可选的基本原理参数(这是带有titleand 的对象message),则此函数将与OS一起检查是否需要显示解释为什么需要权限的对话框(https://developer.android.com/training/ permissions / requests.html#explain),然后显示系统权限对话框

requestMultiple(permissions)

提示用户在同一个对话框中启用多个权限,并返回一个具有权限作为键和字符串的对象作为指示用户是否允许或拒绝请求的值

React native

React Native 是一个 JavaScript 的框架,用来撰写实时的、可原生呈现 iOS 和 Android 的应用。

主页 https://facebook.github.io/react-native/
源码 https://github.com/facebook/react-native
发布版本 0.49

React native目录

1.开始 | Getting Started
2.指南 | Guides
3.APIs
4.组件:ActivityIndicator | Components: ActivityIndicator
5.组件:按钮 | Components: Button
6.组件:CheckBox | Components: CheckBox
7.组件:DatePickerIOS | Components: DatePickerIOS
8.组件:DrawerLayoutAndroid | Components: DrawerLayoutAndroid
9.组件:FlatList | Components: FlatList
10.组件:图像 | Components: Image
11.组件:KeyboardAvoidingView | Components: KeyboardAvoidingView
12.Components: ListView
13.Components: MaskedViewIOS
14.Components: Modal
15.Components: NavigatorIOS
16.Components: Picker
17.Components: PickerIOS
18.Components: ProgressBarAndroid
19.Components: ProgressViewIOS
20.Components: RefreshControl
21.Components: ScrollView
22.Components: SectionList
23.Components: SegmentedControlIOS
24.Components: Slider
25.Components: SnapshotViewIOS
26.Components: StatusBar
27.Components: Switch
28.Components: TabBarIOS
29.Components: TabBarIOS.Item
30.Components: Text
31.Components: TextInput
32.Components: ToolbarAndroid
33.Components: TouchableHighlight
34.Components: TouchableNativeFeedback
35.Components: TouchableOpacity
36.Components: TouchableWithoutFeedback
37.Components: View
38.Components: ViewPagerAndroid
39.Components: VirtualizedList
40.Components: WebView
41.创建 | Contributing
42.指南(Android) | Guides (Android)
43.指南(IOS) | Guides (iOS)
44.其他 | Miscellaneous