# @gcou/react-native-linkedin 中文文档

规范地址：https://npmcn.com/package/%40gcou/react-native-linkedin/

版本：2\.5\.2
npm 元数据更新时间：2026-09-08T15:05:28.470Z
中文译文更新时间：2026-11-16T00:57:16.984Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40gcou/react-native-linkedin
原文对照：https://npmcn.com/package/%40gcou/react-native-linkedin/?lang=original
项目主页：https://github.com/GaelCO/react-native-linkedin
源码仓库：https://github.com/GaelCO/react-native-linkedin

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：29.4 kB，11 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>= 22\.13\.0
- 运行依赖：2 个
- peer 依赖：react \>=19\.1\.0，react-native \>=0\.81\.1，react-native-get-random-values \>=2\.0\.0，react-native-webview \*
- 首次发布：2022-08-05T09:33:09.745Z
- 最新版本发布：2026-09-08T15:05:28.293Z
- 近 30 天下载量：2128（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：19（近 12 个月 3 个）

## 中文简介

React-Native LinkedIn,一个简单的LinkedIn登录库,用于React-Native与WebView和Modal - 兼容RN 0.81.1+

## 安装

```sh
npm install @gcou/react-native-linkedin
```

也可以使用：`pnpm add @gcou/react-native-linkedin`、`yarn add @gcou/react-native-linkedin`、`bun add @gcou/react-native-linkedin`

## README

![react-native-linkedin](https://thumbs.gfycat.com/IlliterateSecondDassie-size_restricted.gif)

### QQ 反应- 内置链接

简单 **链接** 登录库 **反应- Native** 与 _网络视频_ 改为 a _模式_

[![](https://img.shields.io/npm/v/@gcou/react-native-linkedin.svg)](https://www.npmjs.com/package/@gcou/react-native-linkedin) [![](https://img.shields.io/npm/dm/@gcou/react-native-linkedin.svg?style=flat-square)](https://www.npmjs.com/package/@gcou/react-native-linkedin)

  

## 福利

-   **光线**: 不需要像其他选项一样连接本地图书馆
-   **简单**:获取符和过期,您用访问 token处理自己的登录
-   **当然**: 开源
-   **几乎可以读取的代码( C)**: Java脚本和反应

## 安装

```bash
$ yarn add @gcou/react-native-linkedin
```

### 同伴依赖关系

| 软件包 | 最小版本 |
| --- | --- |
| 反应 | (单位:千美元) |
| 反应-内在 | 页:1 |
| 反应-内生-元件-随机值 | 时间: |
| 反应-本地-网络视图 | \* 联合国 |

## 警卫

请注意, 您应该给您的链接客户端 ID , 而不是您的密钥 . 你应该知道,如果直接存储到您的代码中,可以找到密钥. **我强烈建议不要在你的密码上公布客户秘密密钥 但找到办法保密**

-   [\> 链接到文档](https://docs.microsoft.com/en-us/linkedin/shared/api-guide/best-practices/secure-applications?context=linkedin/context#api-key-and-secret-key)

```tsx
  <LinkedInModal
    shouldGetAccessToken={false}
    clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
    redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
    onSuccess={({ authentication_code }) => console.log(`Post this ${authentication_code} to your server.`)}
  />
```

## 示例

```JavaScript
// See ./example/App.tsx file for details
import React, { ReactElement, useRef } from 'react';
import { StyleSheet, View, Button } from 'react-native';

import LinkedInModal, { LinkedInModalRef } from '@gcou/react-native-linkedin';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    alignItems: 'center',
  },
})

export default function AppContainer() : ReactElement {
  const linkedRef = useRef<LinkedInModalRef>(null);
  
  return (
    <View style={styles.container}>
      <LinkedInModal
        ref={linkedRef}
        clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
        clientSecret="[ Your client secret from https://www.linkedin.com/developer/apps ]"
        redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
        onSuccess={token => console.log(token)}
      />
      <Button title="Log Out" onPress={() => linkedRef.current?.logoutAsync()} />
    </View>
  )
}
```

## 道具

| 名称 | 类型 | 需求 | 默认 | 说明 |
| --- | --- | --- | --- | --- |
| 客户端ID | 字符串 | **所需经费** |  | [你的客户身份](https://www.linkedin.com/developer/apps) |
| ~客户端加密~ | 字符串 | 使用情况 **应获取访问token%false\]** 读取 **授权 代码** 成功返回时 |  | 不应存储在应用程序中 [警报! 你的客户秘密](https://docs.microsoft.com/en-us/linkedin/shared/api-guide/best-practices/secure-applications?context=linkedin/context#api-key-and-secret-key) |
| 重定向乌里 | 字符串 | **所需经费** |  | [您的定向Uri](https://www.linkedin.com/developer/apps) |
| 成功时 | 函数 | **所需经费** |  | 函数将召回成功 |
| 认证状态 | 字符串 | 选项 | `require('uuid').v4()` | Author的状态,更安全 |
| 错误 | 函数 | 选项 | `console.error(err)` | 函数会被调回错误 |
| 关闭 | 函数 | 选项 |  | 函数将调用近模式 |
| 打开 | 函数 | 选项 |  | 函数将调用打开的模式 |
| 签名时 | 函数 | 选项 |  | 当用户签名时, 函数会被调回 |
| 权限 | 字符串 \[\] | 选项 | `'r_liteprofile', 'r_emailaddress'` | 访问令牌权限 |
| 渲染按钮 | 反应元素 | 选项 |  | 自定义 Linked In 按钮的渲染 |
| 制作关闭 | 反应元素 | 选项 |  | 自定义关闭按钮 |
| 链接文本 | 字符串 | 选项 | `'Login with LinkedIn'` | 链接标签 |
| 容器样式 | 样式配置 | 选项 |  | 自定义容器样式 |
| 包装板 | 样式配置 | 选项 |  | 自定义包装样式 |
| 关闭样式 | 样式配置 | 选项 |  | 自定义关闭样式 |
| 动画类型 | Modal.props.types.animation Type 互联网档案馆的存檔,存档日期2013-12-22 | 选项 | `fade` | 自定义动画 Type 样式 : “ 无 ” 、 “ 滑行 ” 或 “ 淡出 ” |
| **应当获取访问** | 嘘 | 选项 | `true` | 设定为错误以接收“ 授权代码” 而不是“ 访问符” |
| 区域图文集 | 对象 | 选项 | `{top: 20, bottom: 20, left: 50, right: 50}` | 设定增加文本触摸区域的值 |
| 已失效 | 嘘 | 选项 | `false` | 禁用链接登录按钮 |

## 捐款

-   [@xcarpentier (英语)](mailto:contact@xaviercarpentier.com) 主编.

**欢迎公关!**

## 财务问题

### 它是否在机器人和iOS上都得到支持和测试?

**对**

### 如何登录反应- 本地链接 ?

```tsx
<View style={styles.container}>
    <LinkedInModal
      ref={linkedRef}
      clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
      clientSecret="[ Your client secret from https://www.linkedin.com/developer/apps ]"
      redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
      onSuccess={token => console.log(token)}
    />
    <Button title="Log Out" onPress={() => linkedRef.current?.logoutAsync()} />
</View>
```

## 替代品

-   [反应- 内在链接- login](https://www.npmjs.com/package/react-native-linkedin-login)
-   [反应-内在链接-sdk](https://www.npmjs.com/package/react-native-linkedin-sdk)
-   [反应-内在链接-oauth](https://www.npmjs.com/package/react-native-linkedin-oauth)

## 许可证

[麻省理工学院](https://github.com/GaelCO/react-native-linkedin/blob/master/LICENSE)

> 由 q 制作

## 常见问题

### @gcou/react-native-linkedin 是什么？

React-Native LinkedIn,一个简单的LinkedIn登录库,用于React-Native与WebView和Modal - 兼容RN 0\.81\.1\+

### 如何安装 @gcou/react-native-linkedin？

在项目目录运行 npm install @gcou/react-native-linkedin，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=19\.1\.0）、react-native（\>=0\.81\.1）、react-native-get-random-values（\>=2\.0\.0）、react-native-webview（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @gcou/react-native-linkedin 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/gcou\_\_react-native-linkedin 是否存在。

### @gcou/react-native-linkedin 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @gcou/react-native-linkedin 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 22\.13\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @gcou/react-native-linkedin 可以商用吗？

@gcou/react-native-linkedin 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @gcou/react-native-linkedin 的下载量有多少？

根据 npm 官方下载统计，@gcou/react-native-linkedin 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,128 次，日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @gcou/react-native-linkedin 还在维护吗？

最新版本 2\.5\.2 发布于 2026/09/08（2 个月前）；至今共发布 19 个版本，其中过去 12 个月发布了 3 个；首次发布于 2022/08/05。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

