• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SMS and MMS<a name="EN-US_TOPIC_0000001105544742"></a>
2
3
4## Introduction<a name="section117mcpsimp"></a>
5
6The SMS and MMS module provides the capabilities of sending and receiving short message service \(SMS\) messages and encoding and decoding multimedia messaging service \(MMS\) messages for mobile data users. Its main functions include the following: GSM/CDMA SMS message receiving and sending, SMS protocol data unit \(PDU\) encoding and decoding, WAP Push message receiving and processing, cell broadcast message receiving, MMS message notification, MMS message encoding and decoding, and SIM SMS record management.
7
8**Figure  1**  Architecture of the SMS and MMS module<a name="fig420553511549"></a>
9![](figures/en-us_architecture-of-the-sms-and-mms-module.png)
10
11The SMS and MMS module consists of the following parts:
12
13-   SmsInterfaceManager: provides external APIs for sending SMS messages and managing SIM SMS records. It can be used to create  **SmsSendManager**  and  **SmsReceiveManager**  objects.
14-   SmsSendManager: sends SMS messages and listens to IMS network status changes. It can be used to create  **GsmSmsSender**  and  **CdmaSmsSender**  objects and schedule either object based on the radio access technology \(RAT\) to send SMS messages.
15-   SmsReceiveManager: receives SMS messages and listens to new SMS messages from the RIL Adapter layer. It can be used to create  **GsmSmsReceiveHandler**  and  **CdmaSmsReceiveHandler**  objects as well as the  **SmsWapPushHandler**  and  **SmsCellBroadcastHandler**  objects.
16-   MmsPduProcessor: encodes and decodes MMS PDUs.
17-   ImsSmsClient: sends IMS SMS messages, and sets and obtains IMS SMS configuration information.
18
19## Directory Structure<a name="section125mcpsimp"></a>
20
21```
22/base/telephony/sms_mms
23├─ common                       # Common code
24├─ figures                      # Figures of readme files
25├─ frameworks                   # Frameworks
26│  ├─ js                        # JS code
27│  └─ native                    # Native code
28├─ interfaces                   # APIs
29│  ├─ innerkits                 # Internal APIs
30│  │ └─  ims                    # IMS SMS service APIs
31│  └─ kits                      # External APIs (such as JS APIs)
32├─ sa_profile                   # SA profile
33├─ services                     # IMS service code (for SMS and MMS)
34│  ├─ ims_service_interaction   # IMS service interaction (for SMS and MMS)
35│  ├─ include                   # Header files
36│  ├─ cdma                      # CDMA-specific source files
37│  └─ gsm                       # GSM-specific source files
38├─ test                         # Unit test code
39│  ├─ fuzztest                  # Fuzzy test
40│  ├─ gtest                     # Automated test
41│  └─ unittest                  # Unit test
42└─ utils                        # Utilities
43```
44
45## Constraints<a name="section129mcpsimp"></a>
46
47-   Programming language: JavaScript
48-   In terms of software, this module needs to work with the telephony core service \(core\_service\) and depends on the  [glib](https://gitlab.gnome.org/GNOME/glib).
49-   In terms of hardware, the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.
50
51## Available APIs<a name="section134mcpsimp"></a>
52
53**Table  1**  External APIs provided by the SMS and MMS module
54
55<a name="table136mcpsimp"></a>
56<table><thead align="left"><tr id="row142mcpsimp"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="entry143mcpsimpp0"><a name="entry143mcpsimpp0"></a><a name="entry143mcpsimpp0"></a>API</p>
57</th>
58<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="entry144mcpsimpp0"><a name="entry144mcpsimpp0"></a><a name="entry144mcpsimpp0"></a>Description</p>
59</th>
60<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="entry145mcpsimpp0"><a name="entry145mcpsimpp0"></a><a name="entry145mcpsimpp0"></a>Required Permission</p>
61</th>
62</tr>
63</thead>
64<tbody><tr id="row146mcpsimp"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1011717318415"><a name="p1011717318415"></a><a name="p1011717318415"></a>function sendMessage(options: SendMessageOptions): void;</p>
65</td>
66<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="entry148mcpsimpp0"><a name="entry148mcpsimpp0"></a><a name="entry148mcpsimpp0"></a>Sends SMS messages, including long messages, common messages, and data messages.</p>
67</td>
68<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="entry149mcpsimpp0"><a name="entry149mcpsimpp0"></a><a name="entry149mcpsimpp0"></a>SystemPermission.SEND_MESSAGES</p>
69</td>
70</tr>
71<tr id="row166mcpsimp"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="entry167mcpsimpp0"><a name="entry167mcpsimpp0"></a><a name="entry167mcpsimpp0"></a>function createMessage(pdu: Array&lt;number&gt;, specification: string, callback: AsyncCallback&lt;ShortMessage&gt;): void;</p>
72</td>
73<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p43948592416"><a name="p43948592416"></a><a name="p43948592416"></a>Creates and parses <strong id="b191003398102"><a name="b191003398102"></a><a name="b191003398102"></a>ShortMessage</strong> objects based on PDUs.</p>
74</td>
75<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="entry169mcpsimpp0"><a name="entry169mcpsimpp0"></a><a name="entry169mcpsimpp0"></a>None</p>
76</td>
77</tr>
78</tbody>
79</table>
80
81**Table  2**  Parameter description of SendMessageOptions
82
83<a name="table137771821149"></a>
84<table><thead align="left"><tr id="row16777142181416"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p1677762111420"><a name="p1677762111420"></a><a name="p1677762111420"></a>Parameter</p>
85</th>
86<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.2"><p id="p32826484210"><a name="p32826484210"></a><a name="p32826484210"></a>Type</p>
87</th>
88<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.3"><p id="p117778231415"><a name="p117778231415"></a><a name="p117778231415"></a>Description</p>
89</th>
90<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.4"><p id="p1725516817152"><a name="p1725516817152"></a><a name="p1725516817152"></a>Mandatory</p>
91</th>
92</tr>
93</thead>
94<tbody><tr id="row1577719210142"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p197771201411"><a name="p197771201411"></a><a name="p197771201411"></a>slotId</p>
95</td>
96<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p16282184822111"><a name="p16282184822111"></a><a name="p16282184822111"></a>number</p>
97</td>
98<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p07777221417"><a name="p07777221417"></a><a name="p07777221417"></a>SIM card slot ID</p>
99</td>
100<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p22552080151"><a name="p22552080151"></a><a name="p22552080151"></a>Yes</p>
101</td>
102</tr>
103<tr id="row177779231416"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p12777928146"><a name="p12777928146"></a><a name="p12777928146"></a>destinationHost</p>
104</td>
105<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p19282948182112"><a name="p19282948182112"></a><a name="p19282948182112"></a>string</p>
106</td>
107<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p157771125144"><a name="p157771125144"></a><a name="p157771125144"></a>Phone number of the recipient</p>
108</td>
109<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p192550811156"><a name="p192550811156"></a><a name="p192550811156"></a>Yes</p>
110</td>
111</tr>
112<tr id="row20777162111419"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1777814218147"><a name="p1777814218147"></a><a name="p1777814218147"></a>serviceCenter</p>
113</td>
114<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p0282348112110"><a name="p0282348112110"></a><a name="p0282348112110"></a>string</p>
115</td>
116<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p137781826141"><a name="p137781826141"></a><a name="p137781826141"></a>SMC address</p>
117</td>
118<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1025511815152"><a name="p1025511815152"></a><a name="p1025511815152"></a>No</p>
119</td>
120</tr>
121<tr id="row187781529145"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1377810211419"><a name="p1377810211419"></a><a name="p1377810211419"></a>content</p>
122</td>
123<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p6282648152118"><a name="p6282648152118"></a><a name="p6282648152118"></a>content | Array&lt;number&gt;</p>
124</td>
125<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p47789219147"><a name="p47789219147"></a><a name="p47789219147"></a>SMS content</p>
126</td>
127<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p325517891510"><a name="p325517891510"></a><a name="p325517891510"></a>Yes</p>
128</td>
129</tr>
130<tr id="row37780215141"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p37784221410"><a name="p37784221410"></a><a name="p37784221410"></a>destinationPort</p>
131</td>
132<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p1428274815211"><a name="p1428274815211"></a><a name="p1428274815211"></a>number</p>
133</td>
134<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p87781524149"><a name="p87781524149"></a><a name="p87781524149"></a>Port number for receiving messages</p>
135</td>
136<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p7255386157"><a name="p7255386157"></a><a name="p7255386157"></a>Yes (for sending of data messages)</p>
137</td>
138</tr>
139<tr id="row14778152151417"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1877814231418"><a name="p1877814231418"></a><a name="p1877814231418"></a>sendCallback</p>
140</td>
141<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p3283448172111"><a name="p3283448172111"></a><a name="p3283448172111"></a>AsyncCallback&lt;ISendShortMessageCallback&gt;</p>
142</td>
143<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p16778182121416"><a name="p16778182121416"></a><a name="p16778182121416"></a>Callback of the sending result</p>
144</td>
145<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p7255108141513"><a name="p7255108141513"></a><a name="p7255108141513"></a>Yes</p>
146</td>
147</tr>
148<tr id="row107782241418"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p147781321142"><a name="p147781321142"></a><a name="p147781321142"></a>deliveryCallback</p>
149</td>
150<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p172835481214"><a name="p172835481214"></a><a name="p172835481214"></a>AsyncCallback&lt;IDeliveryShortMessageCallback&gt;</p>
151</td>
152<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p5778624149"><a name="p5778624149"></a><a name="p5778624149"></a>Callback of the delivery report</p>
153</td>
154<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p172553821519"><a name="p172553821519"></a><a name="p172553821519"></a>Yes</p>
155</td>
156</tr>
157</tbody>
158</table>
159
160**Table  3**  Description of ISendShortMessageCallback types
161
162<a name="table6490122972417"></a>
163<table><thead align="left"><tr id="row194901529162416"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p849172910245"><a name="p849172910245"></a><a name="p849172910245"></a>Parameter</p>
164</th>
165<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p849182916242"><a name="p849182916242"></a><a name="p849182916242"></a>Type</p>
166</th>
167<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p144911029162413"><a name="p144911029162413"></a><a name="p144911029162413"></a>Description</p>
168</th>
169</tr>
170</thead>
171<tbody><tr id="row16491142916241"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p549162942410"><a name="p549162942410"></a><a name="p549162942410"></a>result</p>
172</td>
173<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p144911129112418"><a name="p144911129112418"></a><a name="p144911129112418"></a>SendSmsResult</p>
174</td>
175<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p14491129172419"><a name="p14491129172419"></a><a name="p14491129172419"></a>Sending result</p>
176</td>
177</tr>
178<tr id="row204911029112418"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p4491172917241"><a name="p4491172917241"></a><a name="p4491172917241"></a>url</p>
179</td>
180<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1549132914244"><a name="p1549132914244"></a><a name="p1549132914244"></a>string</p>
181</td>
182<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p349115291248"><a name="p349115291248"></a><a name="p349115291248"></a>URL</p>
183</td>
184</tr>
185<tr id="row19491172912247"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p54911329122419"><a name="p54911329122419"></a><a name="p54911329122419"></a>isLastPart</p>
186</td>
187<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p154918290248"><a name="p154918290248"></a><a name="p154918290248"></a>boolean</p>
188</td>
189<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p104913290240"><a name="p104913290240"></a><a name="p104913290240"></a>Whether the SMS message is the last one</p>
190</td>
191</tr>
192</tbody>
193</table>
194
195**Table  4**  Description of SendSmsResult enum values
196
197<a name="table2375639122617"></a>
198<table><thead align="left"><tr id="row1376123932614"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p2376339102616"><a name="p2376339102616"></a><a name="p2376339102616"></a>Name</p>
199</th>
200<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p153769391263"><a name="p153769391263"></a><a name="p153769391263"></a>Value</p>
201</th>
202<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p6376193918267"><a name="p6376193918267"></a><a name="p6376193918267"></a>Description</p>
203</th>
204</tr>
205</thead>
206<tbody><tr id="row1376103912610"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p0376113932616"><a name="p0376113932616"></a><a name="p0376113932616"></a>SEND_SMS_SUCCESS</p>
207</td>
208<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p3376193932611"><a name="p3376193932611"></a><a name="p3376193932611"></a>0</p>
209</td>
210<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1737613982617"><a name="p1737613982617"></a><a name="p1737613982617"></a>Sending succeeded.</p>
211</td>
212</tr>
213<tr id="row20376143917261"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p2037653913260"><a name="p2037653913260"></a><a name="p2037653913260"></a>SEND_SMS_FAILURE_UNKNOWN</p>
214</td>
215<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p4376139182611"><a name="p4376139182611"></a><a name="p4376139182611"></a>1</p>
216</td>
217<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p153761539102611"><a name="p153761539102611"></a><a name="p153761539102611"></a>Sending failed due to an unknown reason.</p>
218</td>
219</tr>
220<tr id="row163766391268"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1376239112618"><a name="p1376239112618"></a><a name="p1376239112618"></a>SEND_SMS_FAILURE_RADIO_OFF</p>
221</td>
222<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1737683972619"><a name="p1737683972619"></a><a name="p1737683972619"></a>2</p>
223</td>
224<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p17376103942619"><a name="p17376103942619"></a><a name="p17376103942619"></a>Sending failed due to modem shutdown.</p>
225</td>
226</tr>
227<tr id="row837613915269"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p143761039162613"><a name="p143761039162613"></a><a name="p143761039162613"></a>SEND_SMS_FAILURE_SERVICE_UNAVAILABLE</p>
228</td>
229<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1237793992616"><a name="p1237793992616"></a><a name="p1237793992616"></a>3</p>
230</td>
231<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p537743910267"><a name="p537743910267"></a><a name="p537743910267"></a>Sending failed due to unavailable network.</p>
232</td>
233</tr>
234</tbody>
235</table>
236
237**Table  5**  Description of IDeliveryShortMessageCallback types
238
239<a name="table13234515285"></a>
240<table><thead align="left"><tr id="row1432445122815"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p1232134532811"><a name="p1232134532811"></a><a name="p1232134532811"></a>Parameter</p>
241</th>
242<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1432114502811"><a name="p1432114502811"></a><a name="p1432114502811"></a>Type</p>
243</th>
244<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p123224515283"><a name="p123224515283"></a><a name="p123224515283"></a>Description</p>
245</th>
246</tr>
247</thead>
248<tbody><tr id="row183254532810"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p9331453286"><a name="p9331453286"></a><a name="p9331453286"></a>pdu</p>
249</td>
250<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p333114542810"><a name="p333114542810"></a><a name="p333114542810"></a>Array&lt;number&gt;</p>
251</td>
252<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1559582618298"><a name="p1559582618298"></a><a name="p1559582618298"></a>PDU array</p>
253</td>
254</tr>
255</tbody>
256</table>
257
258**Table  6**  Parameters of the createMessage API
259
260<a name="table12931820163016"></a>
261<table><thead align="left"><tr id="row8293152043010"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p72931220133012"><a name="p72931220133012"></a><a name="p72931220133012"></a>Parameter</p>
262</th>
263<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p13293172053015"><a name="p13293172053015"></a><a name="p13293172053015"></a>Type</p>
264</th>
265<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p16293162014301"><a name="p16293162014301"></a><a name="p16293162014301"></a>Description</p>
266</th>
267</tr>
268</thead>
269<tbody><tr id="row112937206307"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p13293320193019"><a name="p13293320193019"></a><a name="p13293320193019"></a>pdu</p>
270</td>
271<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p429315201307"><a name="p429315201307"></a><a name="p429315201307"></a>Array&lt;number&gt;</p>
272</td>
273<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p12293102014308"><a name="p12293102014308"></a><a name="p12293102014308"></a>PDU array</p>
274</td>
275</tr>
276<tr id="row6293182012308"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p2293820143020"><a name="p2293820143020"></a><a name="p2293820143020"></a>specification</p>
277</td>
278<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p14293152012301"><a name="p14293152012301"></a><a name="p14293152012301"></a>string</p>
279</td>
280<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1293420163019"><a name="p1293420163019"></a><a name="p1293420163019"></a>Protocol type (3GPP or 3GPP2)</p>
281</td>
282</tr>
283</tbody>
284</table>
285
286## Usage Guidelines<a name="section170mcpsimp"></a>
287
288### Sending SMS Messages<a name="section172mcpsimp"></a>
289
290The function of sending a common SMS message is used as an example. The process is as follows:
291
2921.  Construct a  **SendMessageOptions**  object with required parameters. If the sending result or delivery report is expected, pass the  **sendCallback**  or  **deliveryCallback**  object.
2932.  Call the  **sendMessage**  API in callback or Promise mode.
2943.  Obtain the sending result. The  **sendMessage**  API works in asynchronous mode. The sending result is returned through the callback.
295
296    ```
297    import sms from "@ohos.telephony.sms";
298
299    let msg: SendMessageOptions = {
300      slotId: 1,
301      destinationHost: '12312312312',
302      content: 'This is an SMS message',
303      sendCallback: (err, data) => {
304        if (err) {
305        // If the API call failed, err is not empty.
306          console.error(`failed to send message because ${err.message}`);
307          return;
308        }
309      // If the API call succeeded, err is empty.
310        console.log(`success to send message: ${data.result}`);
311      }
312    }
313
314    // Call the sendMessage API.
315    sms.sendMessage(msg);
316    ```
317
318
319### Creating a ShortMessage Object<a name="section181mcpsimp"></a>
320
321The function of creating a  **ShortMessage**  object with a 3GPP PDU is used as an example. The process is as follows:
322
3231.  Construct the PDU of the SMS message, with the protocol type set to  **3GPP**  or  **3GPP2**.
3242.  Call the  **createMessage**  API in callback or Promise mode.
3253.  The  **createMessage**  API works in asynchronous mode. After the API is called successfully, parse the  **ShortMessage**  object to obtain the SMS message content.
326
327    ```
328    import sms from "@ohos.telephony.sms";
329
330    let pdu = [80, 80, 80]; // The array indicates the PDU of the SMS message other than a real SMS message.
331    let specification = "3gpp";
332
333    // Call the API in callback mode.
334    sms.createMessage(pdu, specification, (err, value) => {
335      if (err) {
336        // If the API call failed, err is not empty.
337        console.error(`failed to createMessage because ${err.message}`);
338        return;
339      }
340      // If the API call succeeded, err is empty.
341      console.log(`success to createMessage: ${value}`);
342    });
343
344    // Call the API in Promise mode.
345    let promise = sms.createMessage(pdu, specification);
346    promise.then((value) => {
347      // The API call succeeded.
348      console.log(`success to createMessage: ${value}`);
349    }).catch((err) => {
350      // The API call failed.
351      console.error(`failed to createMessage because ${err.message}`);
352    });
353    ```
354
355
356## Repositories Involved<a name="section189mcpsimp"></a>
357
358[Telephony](https://gitee.com/openharmony/docs/blob/master/en/readme/telephony.md)
359
360**telephony_sms_mms**
361
362[telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md)
363