提交 e6b99b6f 编写于 作者: WOSHIMAHAIFENG's avatar WOSHIMAHAIFENG

Merge branch 'dev-privacy' into 'dev'

添加隐私策略回调 示例

See merge request !1
......@@ -18,6 +18,8 @@
<button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
......@@ -67,6 +69,7 @@ import {
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api'
import File from 'java.io.File';
import Intent from 'android.content.Intent';
......@@ -106,6 +109,20 @@ export default {
}
})
},
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick() {
this.text = getDeviceInfoTest()
},
......
......@@ -17,6 +17,7 @@
<button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
......@@ -60,7 +61,8 @@
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest
privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api'
/**
* 测试在页面生命周期之外,使用api
......@@ -95,6 +97,20 @@
}
})
},
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick(){
this.text = getDeviceInfoTest()
},
......
......@@ -81,6 +81,22 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo
}
export function privacyStateCallBackTest(callback : (ret : boolean, desc : string) => void) {
let isAgree : boolean = true
const cb = (ret : boolean) => {
console.log('privacyStateCallBackTest->' + ret)
if (ret == isAgree) {
callback(true, "pass")
} else {
callback(false, "callback error")
}
}
// 先重置用户同意状态
const callBackId=UTSAndroid.registerPrivacyAgreeListener(cb)
UTSAndroid.setPrivacyAgree(isAgree)
UTSAndroid.unRegisterPrivacyAgreeListener(callBackId)
}
/**
* UTSAndroid.getAppTempPath 测试示例
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册