...
 
Commits (2)
    https://gitcode.net/dcloud/hello-uts/-/commit/41ebbf85997a983e69dc57c96fed4351d83dadcc 添加隐私策略回调 示例 2024-04-26T11:16:26+08:00 mahaifeng mahaifeng@dcloud.io https://gitcode.net/dcloud/hello-uts/-/commit/e6b99b6f5f3ab7594af78aed40007e6dc06357ca Merge branch 'dev-privacy' into 'dev' 2024-04-26T11:36:46+08:00 WOSHIMAHAIFENG jiayoumahaifeng@163.com 添加隐私策略回调 示例 See merge request <a href="/dcloud/hello-uts/-/merge_requests/1" data-original="dcloud/hello-uts!1" data-link="false" data-link-reference="false" data-project="179408" data-merge-request="83180" data-project-path="dcloud/hello-uts" data-iid="1" data-mr-title="添加隐私策略回调 示例" data-reference-type="merge_request" data-container="body" data-placement="top" title="" class="gfm gfm-merge_request">!1</a>
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
<button @click="dispatchAsyncClick">任务分发测试</button> <button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button> <button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button> <button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> <view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。 1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
...@@ -67,6 +69,7 @@ import { ...@@ -67,6 +69,7 @@ import {
gotoCameraTake, gotoCameraTake,
getDeviceInfoTest, getDeviceInfoTest,
privacyStateTest, privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api' } from '@/uni_modules/uts-platform-api'
import File from 'java.io.File'; import File from 'java.io.File';
import Intent from 'android.content.Intent'; import Intent from 'android.content.Intent';
...@@ -106,6 +109,20 @@ export default { ...@@ -106,6 +109,20 @@ export default {
} }
}) })
}, },
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick() { getDeviceInfoClick() {
this.text = getDeviceInfoTest() this.text = getDeviceInfoTest()
}, },
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<button @click="dispatchAsyncClick">任务分发测试</button> <button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button> <button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button> <button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> <view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。 1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
...@@ -60,7 +61,8 @@ ...@@ -60,7 +61,8 @@
initAppLifecycle, initAppLifecycle,
gotoCameraTake, gotoCameraTake,
getDeviceInfoTest, getDeviceInfoTest,
privacyStateTest privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api' } from '@/uni_modules/uts-platform-api'
/** /**
* 测试在页面生命周期之外,使用api * 测试在页面生命周期之外,使用api
...@@ -95,6 +97,20 @@ ...@@ -95,6 +97,20 @@
} }
}) })
}, },
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick(){ getDeviceInfoClick(){
this.text = getDeviceInfoTest() this.text = getDeviceInfoTest()
}, },
......
...@@ -81,6 +81,22 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo ...@@ -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 测试示例 * UTSAndroid.getAppTempPath 测试示例
*/ */
......