# rntpc_auto-fill **Repository Path**: openharmony-sig/rntpc_auto-fill ## Basic Information - **Project Name**: rntpc_auto-fill - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: https://gitee.com/openharmony-sig/rntpc_auto-fill - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-14 - **Last Updated**: 2025-05-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [rntpc_auto-fill](https://gitcode.com/openharmony-sig/rntpc_auto-fill)。| ⚠️ This repository has been archived. For the new address, please visit [rntpc_auto-fill](https://gitcode.com/openharmony-sig/rntpc_auto-fill).** > --- > # @react-native-ohos-community/auto-fill auto-fill 基于 HarmonyOS [autoFillManager](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-app-ability-autofillmanager-V5) 模块,提供将表单输入数据保存到历史表单输入中,以供下次自动填充的功能,仅支持 ohos 平台。 ## 1. 目录结构 主要目录结构如下: ```yaml auto-fill ├── assets # README静态资源 ├── LICENSE ├── README.md ├── package.json ├── auto-fill # 源码包 │ ├── harmony # native 源码 │ ├── index.ts │ ├── package.json │ └── src └── tester # 使用了 auto-fill 的 react-native 示例工程 ``` ## 2. 前提条件 1. **申请接入智能填充服务** 。当前智能填充处于 Beta 阶段,您可通过发送邮件的方式进行申请接入。邮件模板可参考 [智能填充概述-申请接入智能填充服务](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/scenario-fusion-introduction-to-smart-fill-V5#section1167564853816) 2. 设备智能填充开关必须处于打开状态,请前往“设置 > 隐私和安全 > 智能填充”打开。 3. 设备已连接互联网。 4. 设备需要登录华为账号。 5. 业务侧需要给 `TextInput` 组件传入 [`textContentType`](https://reactnative.cn/docs/textinput#textcontenttype) 属性。 ## 3. 下载及安装 请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-ohos-community/auto-fill Releases](https://github.com/react-native-oh-library/auto-fill/releases),并下载适用版本的 tgz 包。 进入到 react-native 工程目录安装 tgz 包: - **npm** ```bash npm install @react-native-ohos-community/auto-fill@file:path/to/tgz ``` - **yarn** ```bash yarn add @react-native-ohos-community/auto-fill@file::path/to/tgz ``` ## 4. API 接口说明 auto-fill 仅暴露一个 autoSave 接口,用于保存当前表单信息 | API | 说明 | 入参 | 返回值 | | :------------------------------- | ---------------- | :----------------------------------------------: | :----: | | autoSave(onSuccess?, onFailure?) | 保存当前表单信息 | (onSuccess?: () => void, onFailure?: () => void) | void | > autoSave 方法在 native 侧限制 2s 内只能调用一次,多次调用将触发 onFailure 方法,并输出 `autoSave called too frequently, please wait for 2 seconds.` ## 5. 使用说明 ### 5.1. 基本用法 ```tsx import React, { useState } from "react"; import { View, TextInput, Button, StyleSheet } from "react-native"; import AutoFill from "@react-native-ohos-community/auto-fill"; const MyFormComponent = () => { const [fullName, setFullName] = useState(""); const [phoneNumber, setPhoneNumber] = useState(""); const handleSubmit = () => { AutoFill.autoSave( () => { console.log("AutoFillTurboModule success in js is been called"); }, () => { console.log("AutoFillTurboModule failed in js is been called"); } ); }; return (