react-native-nitro-google-signin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReact Native Nitro Google Sign-In
React Native Nitro Google Sign-In
Agent skill (install first for coding agents)
Agent 技能(编码Agent需先安装)
bash
npx skills add react-native-nitro-google-sign-in/google-signin -g -ybash
npx skills add react-native-nitro-google-signin/google-signin -g -yPackage install
包安装
bash
bun add react-native-nitro-google-signin react-native-nitro-modules
bundle exec pod install --project-directory="ios"Requires RN ≥ 0.76. Not Expo Go — use .
expo-dev-clientbash
bun add react-native-nitro-google-signin react-native-nitro-modules
bundle exec pod install --project-directory="ios"要求RN ≥ 0.76。不支持Expo Go — 请使用。
expo-dev-clientRules
规则
| Topic | Rule |
|---|---|
| API | |
| Configure first | |
| Requires |
| Backend | Verify every |
| iOS offline grant | Silent |
| Android: by email/id. iOS: current session only (throws if id mismatch) |
| After sign-in; throws |
| Sync; returns user + |
| Flow order | |
Android | Needs |
| iOS | |
| Expo | Plugin |
| After native changes | Rebuild app — Metro alone is insufficient |
| 主题 | 规则 |
|---|---|
| API | 从 |
| 优先配置 | 登录前先执行 |
| 需要在 |
| 后端 | 在服务端验证每个 |
| iOS 离线授权 | 静默 |
| Android:通过邮箱/ID撤销。iOS:仅撤销当前会话(若ID不匹配会抛出错误) |
| 登录后调用;若无会话会抛出 |
| 同步方法;返回用户信息+ |
| 流程顺序 | |
Android | 需要 |
| iOS | |
| Expo | 插件 |
| 原生代码修改后 | 重新构建应用 — 仅用Metro打包不够 |
Sign-in flow
登录流程
ts
import {
GoogleOneTapSignIn,
isNoSavedCredentialFoundResponse,
isSuccessResponse,
} from 'react-native-nitro-google-signin'
GoogleOneTapSignIn.configure({ webClientId: 'autoDetect' })
await GoogleOneTapSignIn.checkPlayServices()
let response = await GoogleOneTapSignIn.signIn()
if (isNoSavedCredentialFoundResponse(response)) {
response = await GoogleOneTapSignIn.createAccount()
}
if (isNoSavedCredentialFoundResponse(response)) {
response = await GoogleOneTapSignIn.presentExplicitSignIn()
}
if (isSuccessResponse(response)) {
const { user, idToken } = response.data
}ts
import {
GoogleOneTapSignIn,
isNoSavedCredentialFoundResponse,
isSuccessResponse,
} from 'react-native-nitro-google-signin'
GoogleOneTapSignIn.configure({ webClientId: 'autoDetect' })
await GoogleOneTapSignIn.checkPlayServices()
let response = await GoogleOneTapSignIn.signIn()
if (isNoSavedCredentialFoundResponse(response)) {
response = await GoogleOneTapSignIn.createAccount()
}
if (isNoSavedCredentialFoundResponse(response)) {
response = await GoogleOneTapSignIn.presentExplicitSignIn()
}
if (isSuccessResponse(response)) {
const { user, idToken } = response.data
}Platform quick pick
平台快速选择
- Expo → plugin + in
googleServicesFile→ reference.md#expoapp.config.js - Bare Android → SHA-1 + optional Google Services plugin → reference.md#android
- Bare iOS → plist + URL scheme → reference.md#ios
- Expo → 插件 + 在中配置
app.config.js→ reference.md#expogoogleServicesFile - 原生Android → SHA-1 + 可选Google Services插件 → reference.md#android
- 原生iOS → plist文件 + URL scheme → reference.md#ios
Troubleshooting
故障排除
| Symptom | Likely fix |
|---|---|
| Wrong SHA-1 or package on OAuth client |
| Missing Play App Signing / release SHA-1 on Android OAuth client — troubleshooting |
| Add |
| iOS redirect fails | Fix |
| Expo: upgrade package + |
| Nitro not found | Rebuild dev client / |
| Android button laid out but blank | Upgrade package (in-process branding button) + rebuild native app |
| Sign-in OK in debug, fails in release | Consumer ProGuard rules ship with library; avoid |
| 症状 | 可能的解决方法 |
|---|---|
| OAuth客户端的SHA-1或包名错误 |
选择账户后返回 | Android OAuth客户端缺少Play应用签名/发布版SHA-1 — 故障排查 |
提示 | 添加 |
| iOS重定向失败 | 修复 |
| Expo:升级包 + 执行 |
| 提示Nitro未找到 | 重新构建开发客户端 / 执行 |
| Android登录按钮已布局但显示空白 | 升级包(按钮品牌功能正在开发中) + 重新构建原生应用 |
| 调试环境登录正常,发布版失败 | 库已包含消费者ProGuard规则;避免使用 |
More detail
更多细节
- reference.md — API, Expo/bare setup, errors
- examples.md — copy-paste snippets
- Docs: https://react-native-nitro-google-sign-in.github.io/
- reference.md — API、Expo/原生项目配置、错误说明
- examples.md — 可直接复制使用的代码片段
- 文档:https://react-native-nitro-google-sign-in.github.io/