必须使用 expo install
安装。
# 安装 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 expo-tracking-transparency@~5.1.0 react-native-adjust@~5.1.0
# 安装 SDK
$ npx expo install @aidc/account-rn
在 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 广告追踪
});
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);
import { loginWithGoogle, loginWithApple } from '@aidc/account-rn';
const { user, isAppNewUser } = await loginWithGoogle();
import { loginWithApple } from '@aidc/account-rn';
const { user, isAppNewUser } = await loginWithApple();
import { getCurrentUser } from '@aidc/account-rn';
const user = await getCurrentUser();
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();
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',
});
import { logAdjustEvent } from '@aidc/account-rn';
await logAdjustEvent('adjust-event-token');
import { updateAdjustConversionValue } from '@aidc/account-rn';
await updateAdjustConversionValue(1);