HarmonyOS 调用短信服务的api发现权限拒绝

调用短信服务的api发现权限拒绝?由于项目有发送短信授权码的功能,所以咨询一下该功能是否可以在HarmonyOS系统上实现,使用哪种方式实现。

HarmonyOS
2024-12-25 10:54:31
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

可以通过拉起短信应用来完成功能。参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs-V5/faqs-ability-56-V5

参考dmeo:

import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';

@Entry
@Component
struct Index {
  build() {
    Button("跳转到短信").onClick((event: ClickEvent) => {
      let context = getContext(this) as common.UIAbilityContext;
      class info{
        contactName:string
        telephone: string
        // content:String
        constructor() {
          this.contactName = 'ZhangSan'
          this.telephone = '123'
        }

      }
      // class want
      let contactInfo:Array<Object> = new Array()
      contactInfo[0] = new info();
      let want:Want = {
        bundleName: 'com.ohos.mms',
        abilityName: 'com.ohos.mms.MainAbility',
        parameters: {
          contactObjects: JSON.stringify(contactInfo),
          content:"内容",
          pageFlag: 'conversation'
        }
      };
      context.startAbility(want)
        .then(() => {
          //...
        })
        .catch((err:BusinessError) => {
          console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
        });
    }).margin(10)
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
分享
微博
QQ
微信
回复
2024-12-25 13:54:50
相关问题
HarmonyOS 获取拒绝权限
719浏览 • 1回复 待解决
HarmonyOS 如何调用短信应用发送短信
902浏览 • 1回复 待解决
HarmonyOS 权限申请拒绝问题
956浏览 • 1回复 待解决
HarmonyOS webview权限授权被拒绝
907浏览 • 1回复 待解决
读取本地json 文件提示权限拒绝
4110浏览 • 1回复 待解决
HarmonyOS 申请应用跟踪权限被直接拒绝
1079浏览 • 1回复 待解决
HarmonyOS AtManager权限API
364浏览 • 1回复 待解决