沈陽健網(wǎng)站百度推廣管理
1、HamonyOS 樣機(jī)獲取成功返回Oaid為00000000-0000-0000-0000-000000000000?
請求授權(quán)時(shí)需要觸發(fā)動(dòng)態(tài)授權(quán)彈窗,看一下是不是沒有觸發(fā)授權(quán)彈窗。
可以參考以下代碼以及文檔:
// ets
import identifier from '@ohos.identifier.oaid';
import hilog from '@ohos.hilog';
import { BusinessError } from '@ohos.base';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import common from '@ohos.app.ability.common';@Entry
@Component
struct deviceDemo001 {build() {Column() {Text('測試').width('100%').backgroundColor('#131313').height(50).fontColor(Color.White).onClick(()=>{const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();try {let context = getContext(this) as common.UIAbilityContext;atManager.requestPermissionsFromUser(context, ["ohos.permission.APP_TRACKING_CONSENT"]).then((data) => {if (data.authResults[0] == 0) {identifier.getOAID((err: BusinessError, data: string) => {if (err.code) {hilog.error(0x0000, 'testTag', '%{public}s', `get oaid failed, error: ${err.code} ${err.message}`);} else {const oaid: string = data;}});} else {}}).catch((err: BusinessError) => {})} catch(err) {}})}}
}
參考文檔:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/oaid-service-V5
開放匿名設(shè)備標(biāo)識(shí)符(Open Anonymous Device Identifier, OAID,以下簡稱OAID):是一種非永久性設(shè)備標(biāo)識(shí)符,基于開放匿名設(shè)備標(biāo)識(shí)符,可在保護(hù)用戶個(gè)人數(shù)據(jù)隱私安全的前提下,向用戶提供個(gè)性化廣告,同時(shí)三方監(jiān)測平臺(tái)也可以向廣告主提供轉(zhuǎn)化歸因分析。
媒體App、廣告平臺(tái)、三方監(jiān)測平臺(tái)等開發(fā)者,可獲取設(shè)備上的OAID,您可基于OAID進(jìn)行個(gè)性化廣告推薦或廣告轉(zhuǎn)化歸因分析。
OAID是基于華為自有算法生成的32位類UUID(Universally Unique Identifier)標(biāo)識(shí)符,格式為xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx。
OAID的特性:
- OAID是設(shè)備級(jí)標(biāo)識(shí)符,同一臺(tái)設(shè)備上不同的App獲取到的OAID值一樣。
- OAID的獲取受應(yīng)用的“跨應(yīng)用關(guān)聯(lián)訪問權(quán)限”開關(guān)影響:當(dāng)應(yīng)用的“跨應(yīng)用關(guān)聯(lián)訪問權(quán)限”開關(guān)開啟時(shí),該應(yīng)用可獲取到非全0的有效OAID;當(dāng)應(yīng)用的“跨應(yīng)用關(guān)聯(lián)訪問權(quán)限”開關(guān)關(guān)閉時(shí),該應(yīng)用僅能獲取到全0的OAID。
- 同一臺(tái)設(shè)備上首個(gè)應(yīng)用開啟應(yīng)用“跨應(yīng)用關(guān)聯(lián)訪問權(quán)限”開關(guān)時(shí),會(huì)首次生成OAID。
2、HarmonyOS 如何實(shí)現(xiàn)通過NFC實(shí)現(xiàn)手機(jī)給卡充值的功能?
需要的能力是使用NFC適配器建立連接,發(fā)送數(shù)據(jù)和接收數(shù)據(jù),對(duì)應(yīng)的業(yè)務(wù)場景就是使用NFC天線對(duì)公交進(jìn)行充值,NFC讀寫CPU卡的部分,ISO-14443-4協(xié)議規(guī)范
標(biāo)準(zhǔn)NFC-Tag tag.TagInfo demo:
import tag from '@ohos.nfc.tag';
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import Want from '@ohos.app.ability.Want'export default class EntryAbility extends UIAbility {onCreate(want : Want, launchParam: AbilityConstant.LaunchParam) {// add other code here...// want is initialized by nfc service, contains tag info for this found taglet tagInfo : tag.TagInfo | null = null;try {tagInfo = tag.getTagInfo(want);} catch (error) {console.error("tag.getTagInfo catched error: " + error);}if (tagInfo == null || tagInfo == undefined) {console.log("no TagInfo to be created, ignore it.");return;}// get the supported technologies for this found tag.let isNfcATag = false;let isIsoDepTag = false;for (let i = 0; i < tagInfo.technology.length; i++) {if (tagInfo.technology[i] == tag.NFC_A) {isNfcATag = true;}if (tagInfo.technology[i] == tag.ISO_DEP) {isIsoDepTag = true;}// also check for technology: tag.NFC_B/NFC_F/NFC_V/NDEF/MIFARE_CLASSIC/MIFARE_ULTRALIGHT/NDEF_FORMATABLE}// use NfcA APIs to access the found tag.if (isNfcATag) {let nfcA : tag.NfcATag | null = null;try {nfcA = tag.getNfcATag(tagInfo);} catch (error) {console.error("tag.getNfcATag catched error: " + error);}// other code to read or write this found tag.}// use getIsoDep APIs to access the found tag.if (isIsoDepTag) {let isoDep : tag.IsoDepTag | null = null;try {isoDep = tag.getIsoDep(tagInfo);} catch (error) {console.error("tag.getIsoDep catched error: " + error);}// other code to read or write this found tag.}// use the same code to handle for "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable".}
}
3、HarmonyOS css 部分語法會(huì)被標(biāo)紅報(bào)錯(cuò)?
文件是web應(yīng)用打包之后的css文件
因?yàn)槟壳癐DE本身僅支持最基本的那部分CSS語法,所以在項(xiàng)目打開會(huì)看見報(bào)錯(cuò)標(biāo)紅,經(jīng)過測試雖然會(huì)報(bào)錯(cuò),但是不影響app的正常使用。
目前css支持的語法可以參考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/js-framework-syntax-css-V5
4、如何將pc系統(tǒng)剪切板里的內(nèi)容粘貼到模擬器?
- 總體思路通過在模擬器中訪問PC端web頁面的方式,來實(shí)現(xiàn)文本的復(fù)制粘貼。
- PC端開啟web服務(wù)器
- 如果有現(xiàn)成的web服務(wù)器,把需要復(fù)制的文本文件放到web服務(wù)器下即可。
- macOS自帶apache服務(wù)器(推薦)
- 啟用服務(wù):mac命令行執(zhí)行sudo apachectl start服務(wù)啟動(dòng)后,使用PC瀏覽器訪問http://127.0.0.1,能訪問頁面看到"It works!",說明服務(wù)啟動(dòng)成功。
- 修改需要復(fù)制的文本apache服務(wù)的文件根目錄位于/Library/WebServer/Documents新建test.html文件,內(nèi)容為需要復(fù)制的文本,拷貝到/Library/WebServer/Documents即可,PC端訪問地址http://127.0.0.1/test
- windows可下載、運(yùn)行nginx應(yīng)用
- nginx文件根目錄位于nginx/html,默認(rèn)首頁為index.html,修改文本內(nèi)容即可
5、HarmonyOS 關(guān)于ArkTS及so熱更新問題的咨詢?
在Android中很多應(yīng)用會(huì)有熱更的需求,一般有兩種方案:
一種是差分法,可以更新java代碼和so代碼以及一些資源文件;
另一種是通過hook的方式運(yùn)行時(shí)加載包外的so。想詢問一下HarmonyOS下是否有類似的機(jī)制,特別是是否允許從包外加載so
主要是為了解決已經(jīng)上架的包有部分bug不容易簡單修復(fù),需要修改arkts或者C/C++代碼, 但又不希望整包更換的情景
基于HarmonyOS應(yīng)用統(tǒng)一分發(fā)的生態(tài)規(guī)則,不提供補(bǔ)丁的快速熱修復(fù)功能,上述相關(guān)訴求,通過高效的上架審核和應(yīng)用版本更新機(jī)制進(jìn)行保障。