ionic发短信

https://ionicframework.com/docs/native/sms/


SMS

Improve this doc

Requires Cordova plugin: cordova-sms-plugin. For more info, please see the SMS plugin docs.

Repo: https://github.com/cordova-sms/cordova-sms-plugin

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-sms-plugin
    $ npm install --save @ionic-native/sms
    
  2. Add this plugin to your app's module

Supported platforms

  • Android
  • iOS
  • Windows
  • Windows Phone 8

Usage

import { SMS } from '@ionic-native/sms';

constructor(private sms: SMS) { }


...


// Send a text message using default options
this.sms.send('416123456', 'Hello world!');

Instance Members

send(phoneNumber, message, options)

Sends sms to a number

ParamTypeDetails
phoneNumberstring|Array.<string>

Phone number

messagestring

Message

optionsSmsOptions

Options

Returns: Promise<any> Resolves promise when the SMS has been sent

hasPermission()

Platforms:ANDROID 

This function lets you know if the app has permission to send SMS

Returns: Promise<boolean> returns a promise that resolves with a boolean that indicates if we have permission

SmsOptions

ParamTypeDetails
replaceLineBreaksboolean

Set to true to replace \n by a new line. Default: false

(optional)
androidSmsOptionsAndroid(optional)

SmsOptionsAndroid

ParamTypeDetails
intentstring

Set to "INTENT" to send SMS with the native android SMS messaging. Leaving it empty will send the SMS without opening any app.

(optional)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值