Skip to content

初始化 SDK ​

在项目的 App.tsx 或加载首个广告前需初始化 SDK,具体调用参考代码如下:

typescript
import React, { useEffect } from 'react';
import { RNADManager } from '@zmide/react-native-gromore';

export default function App() {
	useEffect(() => {
		// 初始化 react-native-gromore
		RNADManager.init(codes.appid)
			.then((success) => {
			console.log('RNADManager init', success);
			})
			.catch((error) => {
			console.log('RNADManager init failed', error);
			});
	}, []);
	……
}

根据需要可以在初始化 RNADManager 时配置 个性化广告、程序化广告推荐 以及 隐私合规 ,init 可配置隐私配置部分示例如下:

typescript
RNADManager.init(
	codes.appid,
	{
		isLimitPersonalAds: true,// 是否限制个性化广告
		isProgrammaticRecommend: false // 是否开启程序化广告推荐

		// the following parameters are only android
		// https://www.csjplatform.com/supportcenter/5397#18mipxczvs740
		isCanUseLocation: true; // 是否允许获取位置信息
		// 是否允许 SDK 主动使用手机硬件参数,如:imei
		isCanUsePhoneState: true;
		// 当 isCanUsePhoneState=false 时,可传入 imei 信息,穿山甲 sdk 使用您传入的 imei 信息
		devIMEI: 'xxxxxxx-xxxxxxxx';
		// 是否允许 SDK 主动使用 ACCESS_WIFI_STATE 权限
		isCanUseWifiState: true;
		// 是否允许 SDK 主动使用 WRITE_EXTERNAL_STORAGE 权限
		isCanUseWriteExternal: true;
		// 开发者可以传入 oaid
		devOAID: 'xxxxxxx';
		// 是否允许 SDK 主动获取设备上应用安装列表的采集权限
		alist: true;
		// 是否允许 SDK 降低 ANDROID_ID 的采集频率
		isCanUseAndroidId: true;
		// 是否允许 SDK 在申明和授权了的情况下使用录音权限
		isCanUsePermissionRecordAudio: true;
	}
)