uts插件写法
import { DeviceUtil, AppUtil, NotificationUtil, WantUtil, ToastUtil } from '@pura/harmony-utils';
// 打开短信
export function openHmMMS (phone: string, name: string) : void {
console.log('打开的短信号码--------------------------->:', phone, name)
WantUtil.startMMS("13909626520", "张三").then(() => {
ToastUtil.showToast("拉起短信界面…")
}).catch((err: BusinessError) => {
console.log(JSON.stringify(err));
ToastUtil.showToast("拉起失败!");
});
}
//鸿蒙原生写法
import { FileUtil, LogUtil, ToastUtil, WantUtil } from '@pura/harmony-utils';
import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Button("startMMS()")
.btnStyle()
.onClick(() => {
WantUtil.startMMS("13909626520", "张三").then(() => {
ToastUtil.showToast("拉起短信界面…")
}).catch((err: BusinessError) => {
LogUtil.error(JSON.stringify(err));
ToastUtil.showToast("拉起失败!");
});
})
}
.height('100%')
.width('100%')
}
}
@Styles
function btnStyle() {
.width('90%')
.margin({ top: 10, bottom: 5 })
}
0 个回复