# 鸿蒙 HarmonyOS 常见问题
# 1. 集成时常见问题
# 1.1 地图组件和 chooseLocation 等页面地图显示空白
答:请根据文档检查配置是否正确,也可以新建一个鸿蒙工程,使用相同的证书和配置创建一个地图组件,检查是否可以正常显示。
# 2. 使用时常见问题
# 2.1 如何使用自定义 API 打开原生页面?
答:根据场景有不同的实现方式,下面以 Navigation
启动方式举例
- 只是打开原生页面,不需要接受返回参数
import { router } from '@kit.ArkUI'
function navigateToAPP(args: IApiManager.IInvokeArgs, apiManager: ApiManager) {
const params = args.params
const callback = args.callback
router.pushUrl({
url:'CustomApiPage'
})
callback.onSuccess({ data: 'navigateToAPP success !!' })
}
- 跳转到原生页面,并且需要接受返回数据返回给小程序
function navigateToAPP(args: IApiManager.IInvokeArgs, apiManager: ApiManager) {
const params = args.params
const callback = args.callback
FinAppClient.getInstance()?.getEntryInfo().routerState?.pushPath({
name: 'CustomApiPage',
onPop:(info)=>{
callback.onSuccess({ data: info.result })
}
})
}
# 2.2 如何实现自定义开屏并提前告知用户自定义隐私协议?
答:可以使用自定义 loading 页,参考文档
可以参考以下代码,具体业务逻辑请根据实际需求实现:
import { FinAppProxyHandlerManager, IFinProxyHandlerItem } from '@finclip/sdk'
import { CustomLoadingLayout } from '../customLayout/LoadingLayout'
import { common } from '@kit.AbilityKit'
class CustomLayoutHandler extends IFinProxyHandlerItem.CustomLayoutHandler {
context:common.UIAbilityContext
onLoadingLayoutReadyResolve?:()=>void
agreed:boolean = false
constructor(context:common.UIAbilityContext) {
super()
this.context= context
this.context.eventHub.on('agree',()=>{
if( this.onLoadingLayoutReadyResolve){
this.onLoadingLayoutReadyResolve()
this.onLoadingLayoutReadyResolve = undefined
}
this.agreed = true
})
}
onLoadingLayoutReady(): Promise<void> {
return new Promise((resolve) => {
if(this.agreed){
resolve()
}else{
this.onLoadingLayoutReadyResolve = resolve
}
})
}
getCustomLoadingLayout(): (() => void) | void {
return CustomLoadingLayout
}
}
@Builder
export function CustomLoadingLayout() {
CustomViewComponent()
}
@Component
struct CustomViewComponent {
context = getContext(this) as common.UIAbilityContext
aboutToAppear() {
if(this.getPreferencesFromStorage()){
this.onAgree()
}
}
// 从缓存库中获取缓存的数据
async getPreferencesFromStorage() {
}
// 将用户点击同意进行缓存
async putPreference() {
}
// 获取缓存数据
async getPreference(){
}
onCancel() {
}
//同意隐私政策
async onAgree() {
this.context.eventHub.emit('agree')
this.putPreference()
}
build() {
Column(){
Button('同意').onClick(()=>{this.onAgree()})
Button('取消').onClick(()=>{this.onCancel()})
}
.width('100%')
.height('100%')
}
}
export function initCustomLayoutHandler(context:common.UIAbilityContext) {
FinAppProxyHandlerManager.customLayoutHandler = new CustomLayoutHandler(context)
}
# 2.3 录音等 API 不生效?
答:请检查对应权限是否申请