1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15// [Start certificate_management_dialog_box_development_guide] 16import { certificateManagerDialog } from '@kit.DeviceCertificateKit'; 17import { BusinessError } from '@kit.BasicServicesKit'; 18import { common } from '@kit.AbilityKit'; 19 20async function certificateManagerDialogSample() { 21 /* context为应用的上下文信息,由调用方自行获取,此处仅为示例 */ 22 let context: common.Context = getContext(); 23 /* pageType为页面类型,此处赋值PAGE_MAIN,即拉起证书管理主界面 */ 24 let pageType: certificateManagerDialog.CertificateDialogPageType = 25 certificateManagerDialog.CertificateDialogPageType.PAGE_MAIN; 26 try { 27 certificateManagerDialog.openCertificateManagerDialog(context, pageType).then(() => { 28 console.info('Succeeded in opening certificate manager dialog.'); 29 }).catch((err: BusinessError) => { 30 console.error(`Failed to open certificate manager dialog. Code: ${err.code}, message: ${err.message}`); 31 }) 32 } catch (error) { 33 console.error(`Failed to open certificate manager dialog. Code: ${error.code}, message: ${error.message}`); 34 } 35} 36 37 38// [End certificate_management_dialog_box_development_guide] 39@Entry 40@Component 41struct Index { 42 @State message: string = 'CertManagerDialogGuidelines'; 43 44 build() { 45 Column({ space: 5 }) { 46 Text(this.message) 47 .fontWeight(FontWeight.Bold) 48 .fontSize(25) 49 Button($r('app.string.call_certManagerDialogGuidelines')) 50 .width('70%') 51 .onClick(() => { 52 certificateManagerDialogSample(); 53 this.message = 'CertManagerDialogGuidelines Success'; 54 }) 55 } 56 .height('100%') 57 .width('100%') 58 } 59}