1# Telephony Subsystem Changelog 2 3 4 5## cl.telephony.1 SMS Module API Change 6 7Deprecated **sendMessage** and replaced it with **sendShortMessage**. 8 9**Change Impact** 10 11**sendMessage** is deprecated since API version 10. **sendShortMessage** should be used to replace **sendMessage** in application development. The API function remains unchanged. 12 13**Key API/Component Changes** 14 15API before change: 16 17```js 18function sendMessage(options: SendMessageOptions): void; 19``` 20 21API after change: 22 23```js 24function sendShortMessage(options: SendMessageOptions, callback: AsyncCallback<void>): void; 25function sendShortMessage(options: SendMessageOptions): Promise<void>; 26``` 27 28 29 30**Adaptation Guide** 31 32Use the new API. The sample code is as follows: 33 34```js 35import sms from '@ohos.telephony.sms'; 36 37let sendCallback = function (err, data) { 38 console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 39} 40let deliveryCallback = function (err, data) { 41 console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 42} 43let slotId = 0; 44let content ='SMS message content'; 45let destinationHost = '+861xxxxxxxxxx'; 46let serviceCenter = '+861xxxxxxxxxx'; 47let destinationPort = 1000; 48let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; 49sms.sendShortMessage(options, (err) => { 50 console.log(`callback: err->${JSON.stringify(err)}`); 51}); 52``` 53 54```js 55import sms from '@ohos.telephony.sms'; 56 57let sendCallback = function (err, data) { 58 console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 59} 60let deliveryCallback = function (err, data) { 61 console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 62} 63let slotId = 0; 64let content ='SMS message content'; 65let destinationHost = '+861xxxxxxxxxx'; 66let serviceCenter = '+861xxxxxxxxxx'; 67let destinationPort = 1000; 68let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; 69let promise = sms.sendShortMessage(options); 70promise.then(() => { 71 console.log(`sendShortMessage success`); 72}).catch(err => { 73 console.error(`sendShortMessage failed, promise: err->${JSON.stringify(err)}`); 74}); 75 76``` 77 78## cl.telephony.2 SIM Module API Change 79 80Changed the required permission of **getSimTelephoneNumber** from **ohos.permission.GET_TELEPHONY_STATE** to **ohos.permission.GET_PHONE_NUMBERS**. 81 82**Change Impact** 83 84The required permission of **getSimTelephoneNumber** is from **ohos.permission.GET_TELEPHONY_STATE** to **ohos.permission.GET_PHONE_NUMBERS** since API version 10. 85 86An application needs to be apply for the **ohos.permission.GET_PHONE_NUMBERS** permission. The API function remains unchanged. 87 88**Key API/Component Changes** 89 90API before change: 91 92```js 93 @permission ohos.permission.GET_TELEPHONY_STATE 94 function getSimTelephoneNumber(slotId: number, callback: AsyncCallback<string>): void; 95 96 @permission ohos.permission.GET_TELEPHONY_STATE 97 function getSimTelephoneNumber(slotId: number): Promise<string>; 98``` 99 100API after change: 101 102```js 103 @permission ohos.permission.GET_PHONE_NUMBERS 104 function getSimTelephoneNumber(slotId: number, callback: AsyncCallback<string>): void; 105 106 @permission ohos.permission.GET_PHONE_NUMBERS 107 function getSimTelephoneNumber(slotId: number): Promise<string>; 108``` 109 110 111 112**Adaptation Guide** 113 114Use the new API. 115 116In the **module.json** file, add the **ohos.permission.GET_PHONE_NUMBERS** permission or replace the existing permission with it. The sample code is as follows: 117 118```js 119"requestPermissions" : [ 120 { 121 "name": "ohos.permission.GET_PHONE_NUMBERS", 122 "reason": "$string:GET_PHONE_NUMBERS" 123 } 124] 125``` 126