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

兼容端

安卓苹果Web鸿蒙小程序

配置文档

  • 在项目根目录创建 nativeResources -> android -> manifestPlaceholders.json
json
{
	"OPPO_APPKEY": "你的APPKEY",
	"OPPO_APPID": "你的APPID",
	"OPPO_APPSECRET": "你的SECRET"
}
  • 在项目根目录创建 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="com.oppo.push.app_key" android:value="${OPPO_APPKEY}" />
		<meta-data android:name="com.oppo.push.app_secret" android:value="${OPPO_APPSECRET}" />
	</application>
</manifest>

使用文档

  • 先初始化
  • 然后再注册,会拿到registerID。
vue
<script setup lang="uts">
import * as tOppoPushApi from "@/uni_modules/t-oppo-push-api"
import { TOppoPushResult,TOppoPushOptions } from "@/uni_modules/t-oppo-push-api"

const handleInit = () => {
	tOppoPushApi.TInit({
		success: (result:TOppoPushResult) => {
			console.log(result)
		},
		fail: (result:TOppoPushResult) => {
			console.log(result)
		}
	})
}
const handleRegister = () => {
	tOppoPushApi.TRegister({
		appkey: "你的KEY",
		appsecret: "你的Secret",
		success: (result:TOppoPushResult) => {
			console.log(result)
		},
		fail: (result:TOppoPushResult) => {
			console.log(result)
		}
	} as TOppoPushOptions)
}
</script>

暴露的类型

ts
export type TOppoPushResult = {
	code: number;
	msg: string;
	data?: any;
}
export type TOppoPushOptions = {
	appkey?: string; // 注册时必填
	appsecret?: string; // 注册时必填
	success?: (result: TOppoPushResult) => void;
	fail?: (result: TOppoPushResult) => void;
}