1. Send text messages

Uni-app has no corresponding API interface. If you want to send SMS messages, you can use HTML5+ API to directly jump to the SMS page of the mobile phone and edit SMS messages.

Reference links:

www.html5plus.org/doc/zh_cn/m…

To: Recipient information string array type. The entered address recipient information must conform to the message type format.

Cc: array of cc information string. This parameter is valid only when an email is sent. The entered address and recipient information must conform to the message type format.

BCC: Indicates an array of hidden sender information strings. This type is valid only for sending emails. The entered address recipient information must conform to the message type format.

From: The sender information is valid only when the listener listens for the received message.

Subject: indicates the subject of sending messages. The value is a string that is valid only for sending emails.

Body: Indicates the content of the message. The body of the message to be sent must be in the same format as bodyType.

BodyType indicates the type of the body content to be sent. The value can be “text” or “HTML”. The default value is “text”.

Silent: Indicates whether to send the message in silent mode. The value is a Boolean type, which can be true or false. True indicates that the message is sent in silent mode and the interface is not displayed. False: sends data in non-silent mode. Non-silent mode is used by default.

Platform support:

Ios-4.3 + (not supported): silent message sending is not supported and will be ignored.

Android-2.2 + (supported): Supports the silent sending of SMS messages (MMS and emails are not supported). After a message is successfully sent, it is not saved in the mailbox of the system. By default, the message is sent in non-silent mode.

Attachments can be added

2, SMS reading

The following code is obtained by Android. Apple does not support SMS reading.

// Different models may not get all
// Check whether the permission is allowed
var Context = plus.android.runtimeMainActivity();
var res = plus.android.invoke("android.support.v4.app.ActivityCompat"."checkSelfPermission", Context,	"android.permission.READ_SMS");
var PERMISSIONS_STORAGE = new Array(a); PERMISSIONS_STORAGE.push("android.permission.READ_SMS"); 
// if res == -1, the query state is "Show" and "Hidden"
if(res ! ="0") 
{	
    plus.android.invoke("android.support.v4.app.ActivityCompat"."requestPermissions", Context, PERMISSIONS_STORAGE, 1);
} else {	
    var main = plus.android.runtimeMainActivity();
    var Uri = plus.android.importClass("android.net.Uri");
    var ContactsContract = plus.android.importClass('android.provider.ContactsContract');
    var uri = Uri.parse("content://sms/");
    var cr = main.getContentResolver();
    plus.android.importClass(cr);
    var cur = cr.query(uri, null.null.null.null);
    plus.android.importClass(cur);
    cur.moveToFirst();
    while (cur.moveToNext()) 
    {
        var index_Address = cur.getColumnIndex("address");
	var address = cur.getString(index_Address);
	// Message content
  	var index_Body = cur.getColumnIndex("body");
	var body = cur.getString(index_Body);
	Type 1 Receive 2 send
  	var index_Type = cur.getColumnIndex("type");
	var type = cur.getString(index_Type);
	console.log(address,body,type);	
    }
    cur.close();
}Copy the code