14 Star 110 Fork 323

react-native-oh-library/usage-docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.gitee
.idea
en
js
NativeBase.md
Parse-SDK-JS.md
README_EN.md
Shopify-restyle.md
_coverpage.md
_navbar.md
_sidebar.md
ant-design-react-native.md
bam-tech-react-native-image-resizer.md
baronha-ting.md
callstack-react-theme-provider.md
capi-architecture.md
codegen.md
contribute.md
flipper-plugin-react-navigation.md
freakycoder-react-native-bounceable.md
galio-framework.md
gorhom-bottom-sheet.md
jpush-react-native.md
klarna-platform-colors.md
link-source-code.md
lottie-react-native.md
mixpanel-react-native.md
model-gitee.md
model.md
nativewind.md
op-engineering-op-sqlite.md
openspacelabs-react-native-zoomable-view.md
patch.md
react-content-loader.md
react-countdown-circle-timer.md
react-native-MJRefresh.md
react-native-QRCode.md
react-native-SmartRefreshLayout.md
react-native-action-button.md
react-native-action-sheet.md
react-native-alipay.md
react-native-amap-geolocation.md
react-native-amap3d.md
react-native-animatable.md
react-native-animate-number.md
react-native-apple-authentication.md
react-native-aria.md
react-native-async-storage-async-storage.md
react-native-audio-recorder-player.md
react-native-audio-toolkit.md
react-native-audio.md
react-native-autoLink.md
react-native-autocomplete-dropdown.md
react-native-autocomplete-input.md
react-native-autoheight-webview.md
react-native-awesome-gallery.md
react-native-background-fetch.md
react-native-background-timer.md
react-native-baidu-map.md
react-native-barcode-builder.md
react-native-bars.md
react-native-base64.md
react-native-better-banner.md
react-native-bindingx.md
react-native-ble-manager.md
react-native-ble-plx.md
react-native-blob-util.md
react-native-blob-util(nocodegen).md
react-native-blurhash.md
react-native-bootsplash.md
react-native-bouncy-checkbox.md
react-native-button.md
react-native-calendar-events.md
react-native-calendars.md
react-native-callkeep.md
react-native-camera-kit.md
react-native-cameraroll(nocodegen) .md
react-native-cameraroll.md
react-native-canvas.md
react-native-cardview.md
react-native-chart-kit.md
react-native-charts-wrapper.md
react-native-check-box.md
react-native-clipboard-clipboard.md
react-native-clippath-capi.md
react-native-clippathview.md
react-native-code-push.md
react-native-collapsible.md
react-native-color-matrix-image-filters.md
react-native-communications.md
react-native-community-blur.md
react-native-community-checkbox.md
react-native-community-datetimepicker.md
react-native-community-geolocation.md
react-native-community-hooks.md
react-native-community-netinfo.md
react-native-community-progress-bar-android.md
react-native-community-progress-view-capi.md
react-native-community-progress-view.md
react-native-community-push-notification-ios.md
react-native-community-segmented-control.md
react-native-community-slider.md
react-native-community-toolbar-android.md
react-native-compass-heading.md
react-native-confetti-cannon.md
react-native-config.md
react-native-confirmation-code-field.md
react-native-contacts.md
react-native-context-menu-view.md
react-native-cookies-cookies.md
react-native-copilot.md
react-native-country-picker-modal.md
react-native-create-thumbnail.md
react-native-credit-card-input.md
react-native-crypto-js.md
react-native-crypto.md
react-native-custom-keyboard.md
react-native-date-picker(nocodegen).md
react-native-date-picker.md
react-native-deck-swiper.md
react-native-default-preference.md
react-native-device-info.md
react-native-dismiss-keyboard.md
react-native-doc-viewer.md
react-native-document-picker.md
react-native-dotenv.md
react-native-drag-sort.md
react-native-drawer-layout-polyfill.md
react-native-drax.md
react-native-drop-shadow.md
react-native-dropdown-picker.md
react-native-dropdownalert.md
react-native-dynamic.md
react-native-easy-grid.md
react-native-easy-toast.md
react-native-echarts-pro.md
react-native-element-dropdown.md
react-native-elements.md
react-native-email-link.md
react-native-error-boundary.md
react-native-exception-handler.md
react-native-exit-app.md
react-native-ezswiper.md
react-native-fast-image.md
react-native-feather.md
react-native-file-access.md
react-native-file-selector.md
react-native-file-viewer.md
react-native-fileupload.md
react-native-fingerprint-scanner.md
react-native-fit-Image.md
react-native-flash-message.md
react-native-flexi-radio-button.md
react-native-flip-card.md
react-native-fs(nocodegen).md
react-native-fs.md
react-native-gesture-handler.md
react-native-get-random-values.md
react-native-gifted-charts.md
react-native-gifted-chat.md
react-native-graph.md
react-native-haptic-feedback.md
react-native-harmony-sample-package.md
react-native-hole-view.md
react-native-htmlview.md
react-native-http-bridge.md
react-native-hyperlink.md
react-native-iconfont-cli.md
react-native-idfa-aaid.md
react-native-idle-timer.md
react-native-image-capinsets-next.md
react-native-image-colors.md
react-native-image-crop-picker(nocodegen).md
react-native-image-crop-picker.md
react-native-image-editor.md
react-native-image-gallery.md
react-native-image-header-scroll-view.md
react-native-image-marker.md
react-native-image-pan-zoom.md
react-native-image-picker.md
react-native-image-rotate.md
react-native-image-sequence-2.md
react-native-image-viewing.md
react-native-image-zoom-viewer.md
react-native-inappbrowser.md
react-native-incall-manager.md
react-native-indicators.md
react-native-input-scroll-view.md
react-native-intersection-observer.md
react-native-iphone-screen-helper.md
react-native-json-tree.md
react-native-keep-awake.md
react-native-keyboard-accessory.md
react-native-keyboard-aware-scroll-view.md
react-native-keyboard-controller.md
react-native-keys.md
react-native-largelist.md
react-native-lightbox.md
react-native-linear-gradient-text.md
react-native-linear-gradient.md
react-native-loading-spinner-overlay.md
react-native-localization-settings.md
react-native-localization.md
react-native-localize.md
react-native-mail.md
react-native-map-clustering.md
react-native-map-linking.md
react-native-maps-directions.md
react-native-maps.md
react-native-markdown-display.md
react-native-markdown-renderer.md
react-native-marquee-ab.md
react-native-marquee.md
react-native-mask-text.md
react-native-masked-text.md
react-native-masked-view-masked-view.md
react-native-material-buttons.md
react-native-material-design-styles.md
react-native-material-dropdown.md
react-native-material-menu.md
react-native-material-ripple.md
react-native-material-textfield.md
react-native-material-ui.md
react-native-md5.md
react-native-mlkit-ocr.md
react-native-mmkv-storage.md
react-native-modal-popover.md
react-native-modal.md
react-native-modalbox.md
react-native-modals.md
react-native-mqtt.md
react-native-multi-slider.md
react-native-multiple-select.md
react-native-neomorph-shadows.md
react-native-nested-scroll-view.md
react-native-nested-scroll.md
react-native-network-info.md
react-native-nfc-manager.md
react-native-notifier.md
react-native-offline.md
react-native-oh-tpl-react-native-screens.md
react-native-ohos-community-auto-fill.md
react-native-orientation-locker.md
react-native-orientation.md
react-native-pager-view.md
react-native-paper.md
react-native-parsed-text.md
react-native-pdf.md
react-native-performance.md
react-native-permissions.md
react-native-phone-number-input.md
react-native-picker-picker(nocodegen).md
react-native-picker-picker.md
react-native-picker-select.md
react-native-picker.md
react-native-pickers.md
react-native-popover-view.md
react-native-popup-menu.md
react-native-print.md
react-native-progress.md
react-native-pull.md
react-native-qr-decode-image-camera.md
react-native-qrcode-svg.md
react-native-quick-base64.md
react-native-randombytes.md
react-native-ratings.md
react-native-reanimated-bottom-sheet.md
react-native-reanimated-carousel.md
react-native-reanimated-table.md
react-native-reanimated.md
react-native-recaptcha-that-works.md
react-native-reconnecting-websocket.md
react-native-redash.md
react-native-render-html.md
react-native-responsive-fontsize.md
react-native-restart.md
react-native-root-modal.md
react-native-root-siblings.md
react-native-root-toast.md
react-native-safe-area-context.md
react-native-safe-module.md
react-native-safe-modules.md
react-native-screens.md
react-native-screenshot-prevent.md
react-native-scroll-bottom-sheet.md
react-native-scrollable-tab-view.md
react-native-scrollable-tabview.md
react-native-search-bar.md
react-native-secharts.md
react-native-section-list-get-item-layout.md
react-native-securerandom.md
react-native-send-intent.md
react-native-sensitive-info.md
react-native-sensors.md
react-native-shadow-2.md
react-native-shake.md
react-native-share.md
react-native-shared-element.md
react-native-shimmer-placeholder.md
react-native-signature-canvas.md
react-native-signature-capture.md
react-native-simple-toast.md
react-native-size-matters.md
react-native-skia.md
react-native-slider.md
react-native-snackbar.md
react-native-snap-carousel.md
react-native-sortable-list.md
react-native-sound.md
react-native-spinkit.md
react-native-splash-screen.md
react-native-spring-scrollview.md
react-native-sqlite-storage.md
react-native-ssl-pinning.md
react-native-step-indicator.md
react-native-sticky-parallax-header.md
react-native-stickyheader.md
react-native-storage.md
react-native-svg-capi.md
react-native-svg-charts.md
react-native-svg.md
react-native-swipe-gestures.md
react-native-swipe-list-view.md
react-native-swipeable-list.md
react-native-swiper.md
react-native-switch-pro.md
react-native-switch-selector.md
react-native-switch.md
react-native-syan-image-picker.md
react-native-system-setting.md
react-native-tab-navigator.md
react-native-tab-view.md
react-native-tcp-socket.md
react-native-testing-library.md
react-native-text-gradient.md
react-native-text-input-mask.md
react-native-text-size.md
react-native-textinput-maxlength-fixed.md
react-native-theme-control.md
react-native-theme-switch-animation.md
react-native-thumbnail.md
react-native-touch-id.md
react-native-track-player.md
react-native-transitiongroup.md
react-native-translucent-modal.md
react-native-tts.md
react-native-typing-animation.md
react-native-typography.md
react-native-udp.md
react-native-ui-lib.md
react-native-unistyles.md
react-native-url-polyfill.md
react-native-user-agent.md
react-native-vconsole.md
react-native-vector-drawable.md
react-native-vector-icons.md
react-native-version-number.md
react-native-video-cache.md
react-native-video-controls.md
react-native-video.md
react-native-view-overflow.md
react-native-view-pdf.md
react-native-view-shot.md
react-native-vision-camera.md
react-native-voice-voice.md
react-native-walkthrough-tooltip.md
react-native-waterfall-flow.md
react-native-waterflow-list.md
react-native-webview(nocodegen).md
react-native-webview.md
react-native-wechat-lib.md
react-native-worklets-core.md
react-native-zip-archive.md
react-navigation-bottom-sheet.md
react-navigation-bottom-tabs.md
react-navigation-core.md
react-navigation-devtools.md
react-navigation-drawer.md
react-navigation-elements.md
react-navigation-header-buttons.md
react-navigation-material-bottom-tabs.md
react-navigation-material-top-tabs.md
react-navigation-native-stack.md
react-navigation-native.md
react-navigation-routers.md
react-navigation-shared-element.md
react-navigation-stack.md
react-navigation.md
react-subscribe.md
realm-js.md
reanimated-props-backup.md
reassure.md
recyclerlistview.md
remobile-react-native-toast.md
rn-bugly.md
rn-emoji-keyboard.md
rn-placeholder.md
rn-sliding-up-panel.md
rn-tourguide.md
sentry-react-native.md
shopify-flash-list.md
tgz-usage-en.md
usage-docs-checklist.md
victory-native-xl.md
img
zh-cn
.nojekyll
LICENSE
Menu.xlsx
README.md
_404.md
_coverpage.md
_navbar.md
_sidebar.md
index.html
克隆/下载
react-native-camera-kit.md 19.66 KB
一键复制 编辑 原始数据 按行查看 历史

Template version: v0.2.2

react-native-camera-kit

Supported platforms License

[!TIP] Github address

Installation and Usage

Find the matching version information in the release address of a third-party library: @react-native-oh-library/react-native-camera-kit Releases. For older versions that are not published to npm, please refer to the installation guide to install the tgz package.

Go to the project directory and execute the following instruction:

npm

npm install @react-native-oh-tpl/react-native-camera-kit

yarn

yarn add @react-native-oh-tpl/react-native-camera-kit

The following code shows the basic use scenario of the repository:

[!WARNING] The name of the imported repository remains unchanged.

camera example

import React, {useRef, useState} from 'react';
import {Text, StyleSheet, View, Button} from 'react-native';
import {CameraApi, CameraType,Camera} from 'react-native-camera-kit';

export const CameraDemo: React.FC = (): JSX.Element => {
  const nativeRef = useRef<CameraApi>(null);
  const [zoom, setZoom] = useState<number>(0);
  const [errorStr, setErrorStr] = useState<string>('');
  const [photo, setPhoto] = useState<string>('');

  const onError = (e: any) => {
    setErrorStr(e.nativeEvent.errorMessage);
  };

  const onZoom = (e: any) => {
    setZoom(e.nativeEvent.zoom);
  };

  const onPhoto = async () => {
    const result = await nativeRef.current?.capture();
    result && setPhoto(JSON.stringify(result));
  };

  return (
    <>
      <View>
        <Camera
          style={{width: '100%', height: 500}}
          ref={nativeRef}
          maxZoom={10}
          cameraType={CameraType.Back}
          flashMode={0}
          onError={onError}
          onZoom={onZoom}
        />
      </View>
      <View>
        <Button title="onPhoto" onPress={onPhoto} />
        <Text style={styles.text}>zoom:{zoom}</Text>
        <Text style={styles.text}>error:{errorStr}</Text>
        <Text style={styles.text}>photo:{photo}</Text>
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  text: {
    fontSize: 20,
    textAlign: 'center',
    color: '#000',
    marginTop: 10,
  },
});

scanCode example

import React, {useRef, useState} from 'react';
import {Text, StyleSheet, View} from 'react-native';
import {CameraApi, CameraType,Camera} from 'react-native-camera-kit';

export const ScanCodeDemo: React.FC = (): JSX.Element => {
  const nativeRef = useRef<CameraApi>(null);
  const [zoomStr, setZoomStr] = useState<number>(0);
  const [errorStr, setErrorStr] = useState<string>('');
  const [codeResult, setCodeResult] = useState<string>('');

  const onError = (e: any) => {
    setErrorStr(e.nativeEvent.errorMessage);
  };

  const onZoom = (e: any) => {
    setZoomStr(e.nativeEvent.zoom);
  };

  const onReadCode = (e: any) => {
    setCodeResult(JSON.stringify(e));
  };

  return (
    <>
      <View>
        <Camera
          style={{width: 300, height: 400}}
          ref={nativeRef}
          maxZoom={50}
          cameraType={CameraType.Back}
          onError={onError}
          onZoom={onZoom}
          scanBarcode
          onReadCode={onReadCode}
          ratioOverlay="4:3"
        />
      </View>
      <View>
        <Text style={styles.text}>zoom:{zoomStr}</Text>
        <Text style={styles.text}>code:{codeResult}</Text>
        <Text style={styles.text}>error:{errorStr}</Text>
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  text: {
    fontSize: 20,
    textAlign: 'center',
    color: '#000',
    marginTop: 10,
  },
});


Use Codegen

If this repository has been adapted to Codegen, generate the bridge code of the third-party library by using the Codegen. For details, see Codegen Usage Guide.

Link

Currently, HarmonyOS does not support AutoLink. Therefore, you need to manually configure the linking.

Open the harmony directory of the HarmonyOS project in DevEco Studio.

1. Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project

{
  ...
  "overrides": {
    "@rnoh/react-native-openharmony" : "./react_native_openharmony"
  }
}

2. Introducing Native Code

Currently, two methods are available:

Method 1 (recommended): Use the HAR file.

[!TIP] The HAR file is stored in the harmony directory in the installation path of the third-party library.

Open entry/oh-package.json5 file and add the following dependencies:

"dependencies": {
    "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
    "@react-native-oh-tpl/react-native-camera-kit": "file:../../node_modules/@react-native-oh-tpl/react-native-camera-kit/harmony/camera_kit.har"
  }

Click the sync button in the upper right corner.

Alternatively, run the following instruction on the terminal:

cd entry
ohpm install

Method 2: Directly link to the source code.

[!TIP] For details, see Directly Linking Source Code.

3. Configuring CMakeLists and Introducing xxx Package

Open entry/src/main/cpp/CMakeLists.txt and add the following code:

  ...
+ import { RTNCameraKitView } from "@react-native-oh-tpl/react-native-camera-kit";

@Builder
export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
  ...
+ if (ctx.componentName === RTNCameraKitView.NAME) {
+   RTNCameraKitView({
+     ctx: ctx.rnComponentContext,
+     tag: ctx.tag,
+   })
+ }
...
}
...
> [!TIP] If the repository uses a mixed solution, the component name needs to be added.  

Find the constant `arkTsComponentNames` in `entry/src/main/ets/pages/index.ets` or `entry/src/main/ets/rn/LoadBundle.ets` and add the component name to the array.

​```diff
const arkTsComponentNames: Array<string> = [
  SampleView.NAME,
  GeneratedSampleView.NAME,
  PropsDisplayer.NAME,
+ RTNCameraKitView.NAME
  ];

4. Introducing RTNCameraKitPackage to ArkTS

Open the entry/src/main/ets/RNPackagesFactory.ts file and add the following code:

  ...
+ import { RTNCameraKitPackage } from "@react-native-oh-tpl/react-native-camera-kit/ts";

export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
  return [
    new SamplePackage(ctx),
+   new RTNCameraKitPackage(ctx),
  ];
}

5. Running

Click the sync button in the upper right corner.

Alternatively, run the following instruction on the terminal:

cd entry
ohpm install

Then build and run the code.

Constraints

Compatibility

To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.

Check the release version information in the release address of the third-party library: @react-native-oh-library/react-native-camera-kit Releases

Permission Requirements

The following permissions include the system_basic permission, but the default application permission is normal. Only the normal permission can be used. Therefore, the error * 9568289 * * * may be reported during the installation of the HAP package. For details, see Document Change the application level to system_basic.

Add permissions to the module.json5 file in the entry directory.

Open entry/src/main/module.json5 and add the following information:

...
"requestPermissions": [
+  {
+    "name": "ohos.permission.CAMERA",
+    "reason": "$string:camera_reason",
+    "usedScene": {
+      "abilities": [
+        "EntryAbility"
+      ],
+      "when":"inuse"
+    }
+  },
+  {
+    "name": "ohos.permission.MICROPHONE",
+    "reason": "$string:microphone_reason",
+    "usedScene": {
+      "abilities": [
+        "EntryAbility"
+      ],
+      "when":"inuse"
+    }
+  },
+  {
+    "name": "ohos.permission.APPROXIMATELY_LOCATION",
+    "reason": "$string:location_reason",
+    "usedScene": {
+      "abilities": [
+        "EntryAbility"
+      ],
+      "when":"inuse"
+    }
+  }
]

Add the reason for applying for the preceding permission to the entry directory.

Open entry/src/main/resources/base/element/string.json and add the following information:

...
{
  "string": [
+    {
+      "name": "camera_reason",
+      "value": "camera_reason"
+    },
+    {
+      "name": "location_reason",
+      "value": "location_reason"
+    },
+    {
+      "name": "microphone_reason",
+      "value": "microphone_reason"
+    },
  ]
}

Properties

[!tip] The Platform column indicates the platform where the properties are supported in the original third-party library.

[!tip] If the value of HarmonyOS Support is yes, it means that the HarmonyOS platform supports this property; no means the opposite; partially means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.

Camera: CameraComponent

Name Description Type Required Platform HarmonyOS Support
ref Reference on the camera view Ref no All yes
style Style to apply on the camera view StyleProp<ViewStyle> no All yes
flashMode Camera flash mode. Default: auto 'on'/'off'/'auto' no All yes
focusMode Camera focus mode. Default: on 'on'/'off' no All yes
zoomMode Enable the pinch to zoom gesture. Default: on 'on'/'off' no All yes
zoom Control the zoom. Default: 1.0 Number no All yes
maxZoom Maximum zoom allowed (but not beyond what camera allows). Default: undefined (camera default max) Number no All yes
onZoom Callback when user makes a pinch gesture, regardless of what the zoom prop was set to. Returned event contains zoom. Ex: onZoom={(e) => console.log(e.nativeEvent.zoom)}. Function no All yes
torchMode Toggle flash light when camera is active. Default: off 'on'/'off' no All yes
cameraType Choose what camera to use. Default: `CameraType. 'front'/'back' no All yes
onOrientationChange Callback when physical device orientation changes. Returned event contains orientation. Ex: onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}. Use import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... } to understand the new value Function no iOS yes
onError Android only. Callback when camera fails to initialize. Ex: onError={(e) => console.log(e.nativeEvent.errorMessage)}. Function no Android yes
shutterPhotoSound Android only. Enable or disable the shutter sound when capturing a photo. Default: true Boolean no Android yes
ratioOverlay Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: '16:9' String no iOS yes
ratioOverlayColor Any color with alpha. Default: '#ffffff77' String no All yes
resetFocusTimeout Dismiss tap to focus after this many milliseconds. Default 0 (disabled). Example: 5000 is 5 seconds. Number no All yes
resetFocusWhenMotionDetected Dismiss tap to focus when focus area content changes. Native iOS feature, see documentation: https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624644-subjectareachangemonitoringenabl?language=objc). Default true. Boolean no iOS no
resizeMode Determines the scaling and cropping behavior of content within the view. cover (resizeAspectFill on iOS) scales the content to fill the view completely, potentially cropping content if its aspect ratio differs from the view. contain (resizeAspect on iOS) scales the content to fit within the view's bounds without cropping, ensuring all content is visible but may introduce letterboxing. Default behavior depends on the specific use case. 'cover' / 'contain' no iOS no
onCaptureButtonPressIn Callback when iPhone capture button is pressed in. Ex: onCaptureButtonPressIn={() => console.log("volume button pressed in")} Function no iOS yes
onCaptureButtonPressOut Callback when iPhone capture button is released. Ex: onCaptureButtonPressOut={() => console.log("volume button released")} Function no iOS no

ScanCode: ScanCodeComponent

Name Description Type Required Platform HarmonyOS Support
ref Reference on the camera view Ref no All yes
style Style to apply on the camera view StyleProp<ViewStyle> no All yes
flashMode Get secret value 'on'/'off'/'auto' no All yes
zoomMode Enable the pinch to zoom gesture. Default: on 'on'/'off' no All yes
zoom Control the zoom. Default: 1.0 Number no All yes
maxZoom Maximum zoom allowed (but not beyond what camera allows). Default: undefined (camera default max) Number no All yes
onZoom Callback when user makes a pinch gesture, regardless of what the zoom prop was set to. Returned event contains zoom. Ex: onZoom={(e) => console.log(e.nativeEvent.zoom)}. Function no All yes
torchMode Toggle flash light when camera is active. Default: off 'on'/'off' no All yes
cameraType Choose what camera to use. Default: `CameraType. 'front'/'back' no All no
onOrientationChange Callback when physical device orientation changes. Returned event contains orientation. Ex: onOrientationChange={(event) => console.log(event.nativeEvent.orientation)}. Use import { Orientation } from 'react-native-camera-kit'; if (event.nativeEvent.orientation === Orientation.PORTRAIT) { ... } to understand the new value Function no iOS no
onError Android only. Callback when camera fails to initialize. Ex: onError={(e) => console.log(e.nativeEvent.errorMessage)}. Function no Android yes
resetFocusTimeout Dismiss tap to focus after this many milliseconds. Default 0 (disabled). Example: 5000 is 5 seconds. Number no All yes
scanThrottleDelay Duration between scan detection in milliseconds. Default 2000 (2s) Number no All yes
scanBarcode Enable barcode scanner. Default: false boolean no All yes
showFrame Show frame in barcode scanner. Default: false boolean no All yes
laserColor Color of barcode scanner laser visualization. Default: red string no All yes
frameColor Color of barcode scanner frame visualization. Default: yellow string no All yes
onReadCode Callback when scanner successfully reads barcode. Returned event contains codeStringValue. Default: null. Ex: `onReadCode={(event) => console.log(event.nativeEvent.codeStringValue)} Function no All yes

Methods

Name Description Type Required Platform HarmonyOS Support
capture Capture image as JPEG. Promise No All Yes
requestDeviceCameraAuthorization AVAuthorizationStatusAuthorized returns true otherwise, returns false Promise No All Yes
checkDeviceCameraAuthorizationStatus AVAuthorizationStatusAuthorized returns true otherwise, returns false Promise All Yes Yes

Known Issues

  • The sensor rotation angle cannot be queried. issue#1
  • The front camera cannot be used for code scanning. issue#2
  • The flashMode and torchMode attributes cannot be set at the same time. issue#3
  • The onCaptureButtonPressOut attribute is not supported. issue#4
  • The resetFocusWhenMotionDetected attribute is not supported. issue#5
  • The resizeMode attribute is not supported currently. issue#6

Others

License

This project is licensed under The MIT License (MIT).

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/react-native-oh-library/usage-docs.git
git@gitee.com:react-native-oh-library/usage-docs.git
react-native-oh-library
usage-docs
usage-docs
master

搜索帮助