Skip to content
广告位招租广告位招租

兼容端

安卓苹果Web鸿蒙小程序

配置文档

  • 项目根目录配置AndroidManifest.xml
xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
	package="你的包名">

	<application>
		<meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}" />
		<meta-data android:name="JPUSH_CHANNEL" android:value="${JPUSH_CHANNEL}" />
		<!-- 极光 -->
		<activity android:name="你的包名.jverification.MainActivity" />
		<provider android:exported="false" android:authorities="你的包名.jiguang.InitProvider"
			android:name="cn.jpush.android.service.InitProvider"></provider>
		/>
	</application>
</manifest>
  • 项目根目录创建 nativeResources -> android -> manifestPlaceholders.json 文件
json
{
	"JPUSH_PKGNAME": "你的包名",
	"JPUSH_APPKEY": "你的App key",
	"JPUSH_CHANNEL": "developer-default"
}

使用示例 - uni-app x版本

vue
<script setup>
import { 
	tJverifyClearPreLoginCache,
	tJverifyLoginAuth,
	tJverifyPreLogin,
	tJverifyRegister,
	tJverifySetDebugMode,
	tJverifyCheckVerifyEnable,
	TJverifyOptions,
	TJverifyResult
} from "@/uni_modules/t-jverify-api"
const login = () => {
	tJverifyLoginAuth({
		success: (result: TJverifyResult) => {
			console.log(result)
		},
		fail: (result: TJverifyResult) => {
			console.log(result)
		},
	} as TJverifyOptions)
}
onReady(() => {
	tJverifyRegister({
		success: (result1: TJverifyResult) => {
			if(result1.code == 0){
				tJverifyPreLogin({
					success: (result2: TJverifyResult) => {
						console.log(result2.msg)
					},
					fail: (error: TJverifyResult) => {
						console.log(error)
					},
				} as TJverifyOptions)
			}
		},
		fail: (error: TJverifyResult) => {
			console.log(error)
		},
	} as TJverifyOptions)
})
</script>

暴露的类型

ts
export type TJverifyResult = {
	code: number;
	msg: string;
	data?: UTSJSONObject;
}

export type TJverifyOptions = {
	success?: (result: TJverifyResult) => void;
	fail?: (result: TJverifyResult) => void;
}

// #ifdef APP-IOS
export type TJverifyRegisterApi = (options:TJverifyOptions) => void;
export type TJverifySetDebugModeApi = (p:boolean) => void;
export type TJverifyClearPreLoginCacheApi = () => void;
export type TJverifyCheckVerifyEnableApi = () => boolean;
export type TJverifyLoginAuthApi = (options:TJverifyOptions) => void;
export type TJverifyPreLoginApi = (options:TJverifyOptions) => void;
// #endif