18779efd5Sopenharmony_ci/** 28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License. 58779efd5Sopenharmony_ci * You may obtain a copy of the License at 68779efd5Sopenharmony_ci * 78779efd5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88779efd5Sopenharmony_ci * 98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and 138779efd5Sopenharmony_ci * limitations under the License. 148779efd5Sopenharmony_ci */ 158779efd5Sopenharmony_ciimport { HiLog } from '../../../../../common/src/main/ets/util/HiLog'; 168779efd5Sopenharmony_ci 178779efd5Sopenharmony_ciconst TAG = 'MmsService '; 188779efd5Sopenharmony_ci// mms 198779efd5Sopenharmony_ciconst MMS_BUNDLE_NAME = 'com.ohos.mms'; 208779efd5Sopenharmony_ciconst MMS_ABILITY_NAME = 'com.ohos.mms.MainAbility'; 218779efd5Sopenharmony_ciconst MMS_ENTITIES = 'entity.system.home'; 228779efd5Sopenharmony_ci 238779efd5Sopenharmony_ciexport default class MmsService { 248779efd5Sopenharmony_ci static sendMessage(number: string, formatnum:string, name?: string) { 258779efd5Sopenharmony_ci let params = []; 268779efd5Sopenharmony_ci params.push({ 278779efd5Sopenharmony_ci contactsName: name, 288779efd5Sopenharmony_ci telephone: number, 298779efd5Sopenharmony_ci telephoneFormat: formatnum 308779efd5Sopenharmony_ci }); 318779efd5Sopenharmony_ci this.jumpToMms(params); 328779efd5Sopenharmony_ci } 338779efd5Sopenharmony_ci 348779efd5Sopenharmony_ci // Switching to the SMS app 358779efd5Sopenharmony_ci private static jumpToMms(params) { 368779efd5Sopenharmony_ci let actionData: any = {}; 378779efd5Sopenharmony_ci actionData.contactObjects = JSON.stringify(params); 388779efd5Sopenharmony_ci actionData.pageFlag = 'conversation'; 398779efd5Sopenharmony_ci let str = { 408779efd5Sopenharmony_ci 'bundleName': MMS_BUNDLE_NAME, 418779efd5Sopenharmony_ci 'abilityName': MMS_ABILITY_NAME, 428779efd5Sopenharmony_ci 'parameters': actionData, 438779efd5Sopenharmony_ci 'entities': [ 448779efd5Sopenharmony_ci MMS_ENTITIES, 458779efd5Sopenharmony_ci ] 468779efd5Sopenharmony_ci }; 478779efd5Sopenharmony_ci globalThis.context.startAbility(str).then((data) => { 488779efd5Sopenharmony_ci HiLog.i(TAG, 'jumpToMms success.'); 498779efd5Sopenharmony_ci }).catch((error) => { 508779efd5Sopenharmony_ci HiLog.e(TAG, 'jumpToMms failed: %s', JSON.stringify(error.message)); 518779efd5Sopenharmony_ci }) 528779efd5Sopenharmony_ci } 538779efd5Sopenharmony_ci}