@aidc/account-rn
v1.1.17
Published
必须使用 `expo install` 安装 SDK 以及一些 `peerDependencies` 三方依赖。
Readme
账户中心 React Native SDK
安装依赖
必须使用 expo install 安装 SDK 以及一些 peerDependencies 三方依赖。
# 安装 SDK
$ npx expo install @aidc/account-rn
# 安装 peerDependencies
$ npx expo install @react-native-async-storage/async-storage@~2.1.0 @react-native-firebase/analytics@~22.0.0 @react-native-firebase/app@~22.0.0 @react-native-firebase/auth@~22.0.0 @react-native-google-signin/google-signin@~13.2.0 expo-apple-authentication@~7.1.0 expo-build-properties@~0.13.0 react-native-adjust@~5.1.0修改配置
在 app.json 里添加插件。
{
"expo": {
"plugins": ["@aidc/account-rn"]
}
}然后重新预构建一下,再启动应用。
$ npx expo prebuild --clean
$ npx expo run:ios # 或 npx expo run:android初始化
import { setAccountConfig } from '@aidc/account-rn';
setAccountConfig({
env: 'prod', // 指定环境
appId: 'your-app-id', // 由账户中心生成
appVersion: 'your-app-version', // 当前 App 版本号
adjustAppToken: 'your-adjust-app-token', // 可选,用于开启 Adjust 广告追踪
});账户 API
判断邮箱是否注册
import { isEmailExist } from '@aidc/account-rn';
const isEmailExist = await isEmailExist(email);邮箱密码注册
import { registerWithEmailAndPassword } from '@aidc/account-rn';
const { user, isAppNewUser } = await registerWithEmailAndPassword(
email,
password,
);邮箱密码登录
import { loginWithEmailAndPassword } from '@aidc/account-rn';
const { user, isAppNewUser } = await loginWithEmailAndPassword(email, password);Google 授权登录
import { loginWithGoogle, loginWithApple } from '@aidc/account-rn';
const { user, isAppNewUser } = await loginWithGoogle();Apple 授权登录
import { loginWithApple } from '@aidc/account-rn';
const { user, isAppNewUser } = await loginWithApple();获取当前用户
import { getCurrentUser } from '@aidc/account-rn';
const user = await getCurrentUser();获取当前用户的 session token
import { getCurrentSessionToken } from '@aidc/account-rn';
const sessionToken = await getCurrentSessionToken();退出当前用户
import { logoutCurrentUser } from '@aidc/account-rn';
await logoutCurrentUser();注销当前用户
import { deleteCurrentUser } from '@aidc/account-rn';
await deleteCurrentUser();埋点 API
记录页面 PV
import { logPV } from '@aidc/account-rn';
// 记录商品详情页 PV
logPV('product_detail', {
product_id: '123',
product_name: 'product_name',
});记录事件
import { logEvent } from '@aidc/account-rn';
// 记录点击商品事件
logEvent('press', 'product_item', {
product_id: '123',
product_name: 'product_name',
});广告 API
记录事件
import { logAdjustEvent } from '@aidc/account-rn';
await logAdjustEvent('adjust-event-token');更新 SKAN 转化值
import { updateAdjustConversionValue } from '@aidc/account-rn';
await updateAdjustConversionValue(1);