提交 65f93581 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 b268a71d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import call from '@ohos.telephony.call'; import call from '@ohos.telephony.call';
``` ```
...@@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution ...@@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution
**Example** **Example**
``` ```js
call.dial("138xxxxxxxx", (err, data) => { call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron ...@@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Example** **Example**
``` ```js
call.dial("138xxxxxxxx", { call.dial("138xxxxxxxx", {
extras: false extras: false
}, (err, data) => { }, (err, data) => {
...@@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to ...@@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Example** **Example**
``` ```js
let promise = call.dial("138xxxxxxxx", { let promise = call.dial("138xxxxxxxx", {
extras: false extras: false
}); });
...@@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
call.makeCall("138xxxxxxxx", err => { call.makeCall("138xxxxxxxx", err => {
console.log(`makeCall callback: err->${JSON.stringify(err)}`); console.log(`makeCall callback: err->${JSON.stringify(err)}`);
}); });
...@@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
let promise = call.makeCall("138xxxxxxxx"); let promise = call.makeCall("138xxxxxxxx");
promise.then(() => { promise.then(() => {
console.log(`makeCall success`); console.log(`makeCall success`);
...@@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to ...@@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to
**Example** **Example**
``` ```js
call.hasCall((err, data) => { call.hasCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu ...@@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu
**Example** **Example**
``` ```js
let promise = call.hasCall(); let promise = call.hasCall();
promise.then(data => { promise.then(data => {
console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); console.log(`hasCall success, promise: data->${JSON.stringify(data)}`);
...@@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re ...@@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re
**Example** **Example**
``` ```js
call.getCallState((err, data) => { call.getCallState((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result. ...@@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let promise = call.getCallState(); let promise = call.getCallState();
promise.then(data => { promise.then(data => {
console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); console.log(`getCallState success, promise: data->${JSON.stringify(data)}`);
...@@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode ...@@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.| | boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.|
``` ```js
let result = call.hasVoiceCapability(); let result = call.hasVoiceCapability();
console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
``` ```
...@@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg ...@@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example** **Example**
``` ```js
let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1});
promise.then(data => { promise.then(data => {
console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`);
...@@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an ...@@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an
**Example** **Example**
``` ```js
call.formatPhoneNumber("138xxxxxxxx", (err, data) => { call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a ...@@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a
**Example** **Example**
``` ```js
call.formatPhoneNumber("138xxxxxxxx",{ call.formatPhoneNumber("138xxxxxxxx",{
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
...@@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr ...@@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr
**Example** **Example**
``` ```js
let promise = call.formatPhoneNumber("138xxxxxxxx", { let promise = call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}); });
...@@ -465,7 +465,7 @@ All country codes are supported. ...@@ -465,7 +465,7 @@ All country codes are supported.
**Example** **Example**
``` ```js
call.formatPhoneNumberToE164("138xxxxxxxx",{ call.formatPhoneNumberToE164("138xxxxxxxx",{
countryCode: "CN" countryCode: "CN"
}, (err, data) => { }, (err, data) => {
...@@ -501,7 +501,7 @@ All country codes are supported. ...@@ -501,7 +501,7 @@ All country codes are supported.
**Example** **Example**
``` ```js
let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { let promise = call.formatPhoneNumberToE164("138xxxxxxxx", {
countryCode: "CN" countryCode: "CN"
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import contact from '@ohos.contact'; import contact from '@ohos.contact';
``` ```
...@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result. ...@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result.
**Example** **Example**
``` ```js
contact.addContact({ contact.addContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result. ...@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let promise = contact.addContact({ let promise = contact.addContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron ...@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron
**Example** **Example**
``` ```js
contact.deleteContact('xxx', (err) => { contact.deleteContact('xxx', (err) => {
if (err) { if (err) {
console.log(`deleteContact callback: err->${JSON.stringify(err)}`); console.log(`deleteContact callback: err->${JSON.stringify(err)}`);
...@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to ...@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to
**Example** **Example**
``` ```js
let promise = contact.deleteContact('xxx'); let promise = contact.deleteContact('xxx');
promise.then(() => { promise.then(() => {
console.log(`deleteContact success`); console.log(`deleteContact success`);
...@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a ...@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a
**Example** **Example**
``` ```js
contact.updateContact({ contact.updateContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example** **Example**
``` ```js
contact.updateContact({ contact.updateContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example** **Example**
``` ```js
let promise = contact.updateContact({ let promise = contact.updateContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
...@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use ...@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example** **Example**
``` ```js
contact.isLocalContact(/*id*/1, (err, data) => { contact.isLocalContact(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`isLocalContact callback: err->${JSON.stringify(err)}`); console.log(`isLocalContact callback: err->${JSON.stringify(err)}`);
...@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use ...@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example** **Example**
``` ```js
let promise = contact.isLocalContact(/*id*/1); let promise = contact.isLocalContact(/*id*/1);
promise.then((data) => { promise.then((data) => {
console.log(`isLocalContact success: data->${JSON.stringify(data)}`); console.log(`isLocalContact success: data->${JSON.stringify(data)}`);
...@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c ...@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c
**Example** **Example**
``` ```js
contact.isMyCard(/*id*/1, (err, data) => { contact.isMyCard(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`isMyCard callback: err->${JSON.stringify(err)}`); console.log(`isMyCard callback: err->${JSON.stringify(err)}`);
...@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu ...@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu
**Example** **Example**
``` ```js
let promise = contact.isMyCard(/*id*/1); let promise = contact.isMyCard(/*id*/1);
promise.then((data) => { promise.then((data) => {
console.log(`isMyCard success: data->${JSON.stringify(data)}`); console.log(`isMyCard success: data->${JSON.stringify(data)}`);
...@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result. ...@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result.
**Example** **Example**
``` ```js
contact.queryMyCard((err, data) => { contact.queryMyCard((err, data) => {
if (err) { if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`); console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
...@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn ...@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
**Example** **Example**
``` ```js
contact.queryMyCard({ contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes:['ATTR_EMAIL', 'ATTR_NAME']
}, (err, data) => { }, (err, data) => {
...@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ...@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
**Example** **Example**
``` ```js
let promise = contact.queryMyCard({ let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes:['ATTR_EMAIL', 'ATTR_NAME']
}); });
...@@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
contact.selectContact((err, data) => { contact.selectContact((err, data) => {
if (err) { if (err) {
console.log(`selectContact callback: err->${JSON.stringify(err)}`); console.log(`selectContact callback: err->${JSON.stringify(err)}`);
...@@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example** **Example**
``` ```js
let promise = contact.selectContact(); let promise = contact.selectContact();
promise.then((data) => { promise.then((data) => {
console.log(`selectContact success: data->${JSON.stringify(data)}`); console.log(`selectContact success: data->${JSON.stringify(data)}`);
...@@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call ...@@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call
**Example** **Example**
``` ```js
contact.queryContact('xxx', (err, data) => { contact.queryContact('xxx', (err, data) => {
if (err) { if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`); console.log(`queryContact callback: err->${JSON.stringify(err)}`);
...@@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as ...@@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy ...@@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A ...@@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example** **Example**
``` ```js
contact.queryContact('xxx', { contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A ...@@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example** **Example**
``` ```js
let promise = contact.queryContact('xxx', { let promise = contact.queryContact('xxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul ...@@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul
**Example** **Example**
``` ```js
contact.queryContacts((err, data) => { contact.queryContacts((err, data) => {
if (err) { if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`); console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
...@@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch ...@@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr ...@@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API ...@@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example** **Example**
``` ```js
contact.queryContacts({ contact.queryContacts({
holderId: 0 holderId: 0
}, { }, {
...@@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API ...@@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example** **Example**
``` ```js
let promise = contact.queryContacts({ let promise = contact.queryContacts({
holderId: 0 holderId: 0
}, { }, {
...@@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron ...@@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => { contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => {
if (err) { if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`); console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
...@@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u ...@@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us ...@@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute ...@@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example** **Example**
``` ```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', { contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute ...@@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example** **Example**
``` ```js
let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', { let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro ...@@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', (err, data) => { contact.queryContactsByEmail('xxx@email.com', (err, data) => {
if (err) { if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`); console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
...@@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API ...@@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u ...@@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"] attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => { }, (err, data) => {
...@@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut ...@@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example** **Example**
``` ```js
contact.queryContactsByEmail('xxx@email.com', { contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut ...@@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example** **Example**
``` ```js
let promise = contact.queryContactsByEmail('xxx@email.com', { let promise = contact.queryContactsByEmail('xxx@email.com', {
holderId: 0 holderId: 0
}, { }, {
...@@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re ...@@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re
**Example** **Example**
``` ```js
contact.queryGroups((err, data) => { contact.queryGroups((err, data) => {
if (err) { if (err) {
console.log(`queryGroups callback: err->${JSON.stringify(err)}`); console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
...@@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API ...@@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API
**Example** **Example**
``` ```js
contact.queryGroups({ contact.queryGroups({
holderId: 0 holderId: 0
}, (err, data) => { }, (err, data) => {
...@@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API ...@@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API
**Example** **Example**
``` ```js
let promise = contact.queryGroups({ let promise = contact.queryGroups({
holderId: 0 holderId: 0
}); });
...@@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono ...@@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono
**Example** **Example**
``` ```js
contact.queryHolders((err, data) => { contact.queryHolders((err, data) => {
if (err) { if (err) {
console.log(`queryHolders callback: err->${JSON.stringify(err)}`); console.log(`queryHolders callback: err->${JSON.stringify(err)}`);
...@@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to ...@@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to
**Example** **Example**
``` ```js
let promise = contact.queryHolders(); let promise = contact.queryHolders();
promise.then((data) => { promise.then((data) => {
console.log(`queryHolders success: data->${JSON.stringify(data)}`); console.log(`queryHolders success: data->${JSON.stringify(data)}`);
...@@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an ...@@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an
**Example** **Example**
``` ```js
contact.queryKey(/*id*/1, (err, data) => { contact.queryKey(/*id*/1, (err, data) => {
if (err) { if (err) {
console.log(`queryKey callback: err->${JSON.stringify(err)}`); console.log(`queryKey callback: err->${JSON.stringify(err)}`);
...@@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application. ...@@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example** **Example**
``` ```js
contact.queryKey(id, { contact.queryKey(id, {
holderId:1 holderId:1
}, (err, data) => { }, (err, data) => {
...@@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application. ...@@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example** **Example**
``` ```js
let promise = contact.queryKey(id, { let promise = contact.queryKey(id, {
holderId: 0 holderId: 0
}); });
...@@ -1462,7 +1462,7 @@ Defines a contact. ...@@ -1462,7 +1462,7 @@ Defines a contact.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let myContact = { let myContact = {
phoneNumbers: [{ phoneNumbers: [{
phoneNumber: "138xxxxxxxx" phoneNumber: "138xxxxxxxx"
...@@ -1480,7 +1480,7 @@ let myContact = { ...@@ -1480,7 +1480,7 @@ let myContact = {
Or, create data by configuring a new Contact object. Or, create data by configuring a new Contact object.
``` ```js
let myContact = new contact.Contact(); let myContact = new contact.Contact();
let name = new contact.Name(); let name = new contact.Name();
name.fullName = "fullName"; name.fullName = "fullName";
...@@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default. ...@@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let contactAttributes = { let contactAttributes = {
attributes: [ attributes: [
contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_EMAIL,
...@@ -1521,7 +1521,7 @@ let contactAttributes = { ...@@ -1521,7 +1521,7 @@ let contactAttributes = {
Or, create data by configuring a **ContactAttributes** object. Or, create data by configuring a **ContactAttributes** object.
``` ```js
let contactAttributes = new contact.ContactAttributes(); let contactAttributes = new contact.ContactAttributes();
contactAttributes.attributes = ["ATTR_EMAIL"]; contactAttributes.attributes = ["ATTR_EMAIL"];
``` ```
...@@ -1555,7 +1555,7 @@ Enumerates contact attributes. ...@@ -1555,7 +1555,7 @@ Enumerates contact attributes.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE]; let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE];
``` ```
...@@ -1591,7 +1591,7 @@ Defines a contact's email. ...@@ -1591,7 +1591,7 @@ Defines a contact's email.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let email = { let email = {
email: "xxx@email.com", email: "xxx@email.com",
displayName: "displayName" displayName: "displayName"
...@@ -1601,7 +1601,7 @@ let email = { ...@@ -1601,7 +1601,7 @@ let email = {
Or, create data by configuring an **Email** object. Or, create data by configuring an **Email** object.
``` ```js
let email = new contact.Email(); let email = new contact.Email();
email.email = "xxx@email.com"; email.email = "xxx@email.com";
``` ```
...@@ -1624,7 +1624,7 @@ Defines an application that creates the contact. ...@@ -1624,7 +1624,7 @@ Defines an application that creates the contact.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let holder = { let holder = {
holderId: 0 holderId: 0
}; };
...@@ -1632,7 +1632,7 @@ let holder = { ...@@ -1632,7 +1632,7 @@ let holder = {
Or, create data by configuring a **Holder** object. Or, create data by configuring a **Holder** object.
``` ```js
let holder = new contact.Holder(); let holder = new contact.Holder();
holder.holderId = 0; holder.holderId = 0;
``` ```
...@@ -1668,7 +1668,7 @@ Defines a contact's event. ...@@ -1668,7 +1668,7 @@ Defines a contact's event.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let event = { let event = {
eventDate: "xxxxxx" eventDate: "xxxxxx"
}; };
...@@ -1676,7 +1676,7 @@ let event = { ...@@ -1676,7 +1676,7 @@ let event = {
Or, create data by configuring an **Event** object. Or, create data by configuring an **Event** object.
``` ```js
let event = new contact.Event(); let event = new contact.Event();
event.eventDate = "xxxxxx"; event.eventDate = "xxxxxx";
``` ```
...@@ -1698,7 +1698,7 @@ Defines a contact group. ...@@ -1698,7 +1698,7 @@ Defines a contact group.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let group = { let group = {
groupId: 1, groupId: 1,
title: "title" title: "title"
...@@ -1707,7 +1707,7 @@ let group = { ...@@ -1707,7 +1707,7 @@ let group = {
Or, create data by configuring a **Group** object. Or, create data by configuring a **Group** object.
``` ```js
let group = new contact.Group(); let group = new contact.Group();
group.title = "title"; group.title = "title";
``` ```
...@@ -1747,7 +1747,7 @@ Enumerates IM addresses. ...@@ -1747,7 +1747,7 @@ Enumerates IM addresses.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let imAddress = { let imAddress = {
imAddress: "imAddress", imAddress: "imAddress",
labelName: "labelName" labelName: "labelName"
...@@ -1757,7 +1757,7 @@ let imAddress = { ...@@ -1757,7 +1757,7 @@ let imAddress = {
Or, create data by configuring an **ImAddress** object. Or, create data by configuring an **ImAddress** object.
``` ```js
let imAddress = new contact.ImAddress(); let imAddress = new contact.ImAddress();
imAddress.imAddress = "imAddress"; imAddress.imAddress = "imAddress";
``` ```
...@@ -1786,7 +1786,7 @@ Defines a contact's name. ...@@ -1786,7 +1786,7 @@ Defines a contact's name.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let name = { let name = {
familyName: "familyName", familyName: "familyName",
fullName: "fullName" fullName: "fullName"
...@@ -1795,7 +1795,7 @@ let name = { ...@@ -1795,7 +1795,7 @@ let name = {
Or, create data by configuring a **Name** object. Or, create data by configuring a **Name** object.
``` ```js
let name = new contact.Name(); let name = new contact.Name();
name.familyName = "familyName"; name.familyName = "familyName";
name.fullName = "fullName"; name.fullName = "fullName";
...@@ -1817,7 +1817,7 @@ Defines a contact's nickname. ...@@ -1817,7 +1817,7 @@ Defines a contact's nickname.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let nickName = { let nickName = {
nickName: "nickName" nickName: "nickName"
}; };
...@@ -1825,7 +1825,7 @@ let nickName = { ...@@ -1825,7 +1825,7 @@ let nickName = {
Or, create data by configuring a **NickName** object. Or, create data by configuring a **NickName** object.
``` ```js
let nickName = new contact.NickName(); let nickName = new contact.NickName();
nickName.nickName = "nickName"; nickName.nickName = "nickName";
``` ```
...@@ -1846,7 +1846,7 @@ Defines a contact's note. ...@@ -1846,7 +1846,7 @@ Defines a contact's note.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let note = { let note = {
noteContent: "noteContent" noteContent: "noteContent"
}; };
...@@ -1854,7 +1854,7 @@ let note = { ...@@ -1854,7 +1854,7 @@ let note = {
Or, create data by configuring a **Note** object. Or, create data by configuring a **Note** object.
``` ```js
let note = new contact.Note(); let note = new contact.Note();
note.noteContent = "noteContent"; note.noteContent = "noteContent";
``` ```
...@@ -1876,7 +1876,7 @@ Defines a contact's organization. ...@@ -1876,7 +1876,7 @@ Defines a contact's organization.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let organization = { let organization = {
name: "name", name: "name",
title: "title" title: "title"
...@@ -1885,7 +1885,7 @@ let organization = { ...@@ -1885,7 +1885,7 @@ let organization = {
Or, create data by configuring an **Organization** object. Or, create data by configuring an **Organization** object.
``` ```js
let organization = new contact.Organization(); let organization = new contact.Organization();
organization.name = "name"; organization.name = "name";
organization.title = "title"; organization.title = "title";
...@@ -1939,7 +1939,7 @@ Defines a contact's phone number. ...@@ -1939,7 +1939,7 @@ Defines a contact's phone number.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let phoneNumber = { let phoneNumber = {
phoneNumber: "138xxxxxxxx", phoneNumber: "138xxxxxxxx",
labelId: contact.PhoneNumber.NUM_HOME labelId: contact.PhoneNumber.NUM_HOME
...@@ -1948,7 +1948,7 @@ let phoneNumber = { ...@@ -1948,7 +1948,7 @@ let phoneNumber = {
Or, create data by configuring a new **PhoneNumber** object. Or, create data by configuring a new **PhoneNumber** object.
``` ```js
let phoneNumber = new contact.PhoneNumber(); let phoneNumber = new contact.PhoneNumber();
phoneNumber.phoneNumber = "138xxxxxxxx"; phoneNumber.phoneNumber = "138xxxxxxxx";
``` ```
...@@ -1969,7 +1969,7 @@ Defines a contact's portrait. ...@@ -1969,7 +1969,7 @@ Defines a contact's portrait.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let portrait = { let portrait = {
uri: "uri" uri: "uri"
}; };
...@@ -1977,7 +1977,7 @@ let portrait = { ...@@ -1977,7 +1977,7 @@ let portrait = {
Or, create data by configuring a new **Portrait** object. Or, create data by configuring a new **Portrait** object.
``` ```js
let portrait = new contact.Portrait(); let portrait = new contact.Portrait();
portrait.uri = "uri"; portrait.uri = "uri";
``` ```
...@@ -2020,7 +2020,7 @@ Defines a contact's postal address. ...@@ -2020,7 +2020,7 @@ Defines a contact's postal address.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let postalAddress = { let postalAddress = {
city: "city" city: "city"
}; };
...@@ -2028,7 +2028,7 @@ let postalAddress = { ...@@ -2028,7 +2028,7 @@ let postalAddress = {
Or, create data by configuring a new **PostalAddress** object. Or, create data by configuring a new **PostalAddress** object.
``` ```js
let postalAddress = new contact.PostalAddress(); let postalAddress = new contact.PostalAddress();
postalAddress.city = "city"; postalAddress.city = "city";
``` ```
...@@ -2075,7 +2075,7 @@ Defines a contact's relationship. ...@@ -2075,7 +2075,7 @@ Defines a contact's relationship.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let relation = { let relation = {
relationName: "relationName", relationName: "relationName",
labelId: contact.Relation.RELATION_ASSISTANT labelId: contact.Relation.RELATION_ASSISTANT
...@@ -2084,7 +2084,7 @@ let relation = { ...@@ -2084,7 +2084,7 @@ let relation = {
Or, create data by configuring a new **Relation** object. Or, create data by configuring a new **Relation** object.
``` ```js
let relation = new contact.Relation(); let relation = new contact.Relation();
relation.relationName = "relationName"; relation.relationName = "relationName";
relation.labelId = contact.Relation.RELATION_ASSISTANT; relation.labelId = contact.Relation.RELATION_ASSISTANT;
...@@ -2121,7 +2121,7 @@ Defines a contact's SIP address. ...@@ -2121,7 +2121,7 @@ Defines a contact's SIP address.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
var sipAddress = { var sipAddress = {
sipAddress: "sipAddress" sipAddress: "sipAddress"
}; };
...@@ -2129,7 +2129,7 @@ var sipAddress = { ...@@ -2129,7 +2129,7 @@ var sipAddress = {
Or, create data by configuring a new **SipAddress** object. Or, create data by configuring a new **SipAddress** object.
``` ```js
let sipAddress = new contact.SipAddress(); let sipAddress = new contact.SipAddress();
sipAddress.sipAddress = "sipAddress"; sipAddress.sipAddress = "sipAddress";
``` ```
...@@ -2150,7 +2150,7 @@ Defines a contact's website. ...@@ -2150,7 +2150,7 @@ Defines a contact's website.
Create contact data in JSON format: Create contact data in JSON format:
``` ```js
let website = { let website = {
website: "website" website: "website"
}; };
...@@ -2158,7 +2158,7 @@ let website = { ...@@ -2158,7 +2158,7 @@ let website = {
Or, create data by configuring a new **Website** object. Or, create data by configuring a new **Website** object.
``` ```js
let website = new contact.Website(); let website = new contact.Website();
website.website = "website"; website.website = "website";
``` ```
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
## Modules to Import ## Modules to Import
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
``` ```
## Example ## Example
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. // Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused.
...@@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req ...@@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
**Example** **Example**
``` ```js
import http from '@ohos.net.http'; import http from '@ohos.net.http';
let httpRequest = http.createHttp(); let httpRequest = http.createHttp();
``` ```
...@@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Example** **Example**
``` ```js
httpRequest.request("EXAMPLE_URL", (err, data) => { httpRequest.request("EXAMPLE_URL", (err, data) => {
if (!err) { if (!err) {
console.info('Result:' + data.result); console.info('Result:' + data.result);
...@@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example** **Example**
``` ```js
httpRequest.request("EXAMPLE_URL", httpRequest.request("EXAMPLE_URL",
{ {
method: http.RequestMethod.GET, method: http.RequestMethod.GET,
...@@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the ...@@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
**Example** **Example**
``` ```js
let promise = httpRequest.request("EXAMPLE_URL", { let promise = httpRequest.request("EXAMPLE_URL", {
method: http.RequestMethod.GET, method: http.RequestMethod.GET,
connectTimeout: 60000, connectTimeout: 60000,
...@@ -214,7 +214,7 @@ Destroys an HTTP request. ...@@ -214,7 +214,7 @@ Destroys an HTTP request.
**Example** **Example**
``` ```js
httpRequest.destroy(); httpRequest.destroy();
``` ```
...@@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events. ...@@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.on('headerReceive', (err, data) => { httpRequest.on('headerReceive', (err, data) => {
if (!err) { if (!err) {
console.info('header: ' + JSON.stringify(data)); console.info('header: ' + JSON.stringify(data));
...@@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events. ...@@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.off('headerReceive'); httpRequest.off('headerReceive');
``` ```
...@@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events. ...@@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.on('headersReceive', (header) => { httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
...@@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events. ...@@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events.
**Example** **Example**
``` ```js
httpRequest.off('headersReceive'); httpRequest.off('headersReceive');
``` ```
...@@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t ...@@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t
**Example** **Example**
``` ```js
httpRequest.once('headersReceive', (header) => { httpRequest.once('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
```javascript ```js
import connection from '@ohos.net.connection' import connection from '@ohos.net.connection'
``` ```
...@@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback ...@@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback
**Example** **Example**
```javascript ```js
connection.getDefaultNet(function (error, netHandle) { connection.getDefaultNet(function (error, netHandle) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(JSON.stringify(netHandle)) console.log(JSON.stringify(netHandle))
...@@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r ...@@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
console.log(JSON.stringify(netHandle)) console.log(JSON.stringify(netHandle))
}) })
...@@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron ...@@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron
**Example** **Example**
```javascript ```js
connection.hasDefaultNet(function (error, has) { connection.hasDefaultNet(function (error, has) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(has) console.log(has)
...@@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to ...@@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to
**Example** **Example**
```javascript ```js
connection.hasDefaultNet().then(function (has) { connection.hasDefaultNet().then(function (has) {
console.log(has) console.log(has)
}) })
...@@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call ...@@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call
**Example** **Example**
``` ```js
connection.getAllNets(function (error, nets) { connection.getAllNets(function (error, nets) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
console.log(JSON.stringify(nets)) console.log(JSON.stringify(nets))
...@@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return ...@@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return
**Example** **Example**
``` ```js
connection.getAllNets().then(function (nets) { connection.getAllNets().then(function (nets) {
console.log(JSON.stringify(nets)) console.log(JSON.stringify(nets))
}); });
...@@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand ...@@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle, function (error, info) { connection.getConnectionProperties(netHandle, function (error, info) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi ...@@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle).then(function (info) { connection.getConnectionProperties(netHandle).then(function (info) {
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
...@@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th ...@@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle, function (error, info) { connection.getNetCapabilities(netHandle, function (error, info) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th ...@@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle).then(function (info) { connection.getNetCapabilities(netHandle).then(function (info) {
console.log(JSON.stringify(info)) console.log(JSON.stringify(info))
...@@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t ...@@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle, function (error) { connection.reportNetConnected(netHandle, function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re ...@@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle).then(function () { connection.reportNetConnected(netHandle).then(function () {
console.log(`report success`) console.log(`report success`)
...@@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac ...@@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle, function (error) { connection.reportNetDisconnected(netHandle, function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the ...@@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the
**Example** **Example**
``` ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle).then(function () { connection.reportNetDisconnected(netHandle).then(function () {
console.log(`report success`) console.log(`report success`)
...@@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example** **Example**
``` ```js
let host = "xxxx"; let host = "xxxx";
connection.getAddressesByName(host, function (error, addresses) { connection.getAddressesByName(host, function (error, addresses) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
...@@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses. ...@@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example** **Example**
``` ```js
let host = "xxxx"; let host = "xxxx";
connection.getAddressesByName(host).then(function (addresses) { connection.getAddressesByName(host).then(function (addresses) {
console.log(JSON.stringify(addresses)) console.log(JSON.stringify(addresses))
...@@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**. ...@@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**.
**Example** **Example**
```javascript ```js
// Default network // Default network
let netConnection = connection.createNetConnection() let netConnection = connection.createNetConnection()
...@@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events. ...@@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events.
**Example** **Example**
```javascript ```js
netConnection.on('netAvailable', function (data) { netConnection.on('netAvailable', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events. ...@@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netCapabilitiesChange', function (data) { netConnection.on('netCapabilitiesChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events. ...@@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netConnectionPropertiesChange', function (data) { netConnection.on('netConnectionPropertiesChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events. ...@@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events.
**Example** **Example**
```javascript ```js
netConnection.on('netBlockStatusChange', function (data) { netConnection.on('netBlockStatusChange', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -594,7 +594,7 @@ Registers a listener for **netLost** events. ...@@ -594,7 +594,7 @@ Registers a listener for **netLost** events.
**Example** **Example**
```javascript ```js
let netConnection1 = connection.createNetConnection() let netConnection1 = connection.createNetConnection()
netConnection1.on('netLost', function (data) { netConnection1.on('netLost', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
...@@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events. ...@@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events.
**Example** **Example**
```javascript ```js
netConnection.on('netUnavailable', function (data) { netConnection.on('netUnavailable', function (data) {
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}) })
...@@ -642,7 +642,7 @@ Registers a listener for network status changes. ...@@ -642,7 +642,7 @@ Registers a listener for network status changes.
**Example** **Example**
```javascript ```js
netConnection.register(function (error) { netConnection.register(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
...@@ -664,7 +664,7 @@ Unregisters the listener for network status changes. ...@@ -664,7 +664,7 @@ Unregisters the listener for network status changes.
**Example** **Example**
```javascript ```js
netConnection.unregister(function (error) { netConnection.unregister(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
...@@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressesByName(host, function (error, addresses) { netHandle.getAddressesByName(host, function (error, addresses) {
...@@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre ...@@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressesByName(host).then(function (addresses) { netHandle.getAddressesByName(host).then(function (addresses) {
...@@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressByName(host, function (error, address) { netHandle.getAddressByName(host, function (error, address) {
...@@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP ...@@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example** **Example**
```javascript ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx"; let host = "xxxx";
netHandle.getAddressByName(host).then(function (address) { netHandle.getAddressByName(host).then(function (address) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import observer from '@ohos.telephony.observer' import observer from '@ohos.telephony.observer'
``` ```
...@@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr ...@@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr
**Example** **Example**
``` ```js
observer.on('networkStateChange', data =>{ observer.on('networkStateChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp ...@@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp
**Example** **Example**
``` ```js
observer.on('networkStateChange', {slotId: 0}, data =>{ observer.on('networkStateChange', {slotId: 0}, data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn ...@@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
} }
...@@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro ...@@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro
**Example** **Example**
``` ```js
observer.on('signalInfoChange', data =>{ observer.on('signalInfoChange', data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
}); });
...@@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe ...@@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe
**Example** **Example**
``` ```js
observer.on('signalInfoChange', {slotId: 0}, data =>{ observer.on('signalInfoChange', {slotId: 0}, data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
}); });
...@@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async ...@@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on signalInfoChange, data:" + JSON.stringify(data)); console.log("on signalInfoChange, data:" + JSON.stringify(data));
} }
...@@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example** **Example**
``` ```js
observer.on('callStateChange', value =>{ observer.on('callStateChange', value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}); });
...@@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example** **Example**
``` ```js
observer.on('callStateChange', {slotId: 0}, value =>{ observer.on('callStateChange', {slotId: 0}, value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}); });
...@@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr ...@@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr
**Example** **Example**
``` ```js
let callback = value => { let callback = value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number); console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
} }
...@@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l
**Example** **Example**
``` ```js
observer.on('cellularDataConnectionStateChange', value =>{ observer.on('cellularDataConnectionStateChange', value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}); });
...@@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l ...@@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l
**Example** **Example**
``` ```js
observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}); });
...@@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat ...@@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat
**Example** **Example**
``` ```js
let callback = value => { let callback = value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
} }
...@@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example** **Example**
``` ```js
observer.on('cellularDataFlowChange', data =>{ observer.on('cellularDataFlowChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data)); console.log("on networkStateChange, data:" + JSON.stringify(data));
}); });
...@@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example** **Example**
``` ```js
observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ observer.on('cellularDataFlowChange', {slotId: 0}, data =>{
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
}); });
...@@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve ...@@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
} }
...@@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch ...@@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch
**Example** **Example**
``` ```js
observer.on('simStateChange', data =>{ observer.on('simStateChange', data =>{
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
}); });
...@@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified ...@@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified
**Example** **Example**
``` ```js
observer.on('simStateChange', {slotId: 0}, data =>{ observer.on('simStateChange', {slotId: 0}, data =>{
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
}); });
...@@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy ...@@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy
**Example** **Example**
``` ```js
let callback = data => { let callback = data => {
console.log("on simStateChange, data:" + JSON.stringify(data)); console.log("on simStateChange, data:" + JSON.stringify(data));
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import radio from '@ohos.telephony.radio' import radio from '@ohos.telephony.radio'
``` ```
...@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP ...@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{ radio.getRadioTech(slotId, (err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return ...@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getRadioTech(slotId); let promise = radio.getRadioTech(slotId);
promise.then(data => { promise.then(data => {
...@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example** **Example**
``` ```js
radio.getNetworkState((err, data) =>{ radio.getNetworkState((err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getNetworkState(slotId, (err, data) => { radio.getNetworkState(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses ...@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getNetworkState(slotId); let promise = radio.getNetworkState(slotId);
promise.then(data => { promise.then(data => {
...@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => { radio.getNetworkSelectionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId); let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => { promise.then(data => {
...@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => { radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId); let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => { promise.then(data => {
...@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example** **Example**
``` ```js
radio.getPrimarySlotId((err, data) => { radio.getPrimarySlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example** **Example**
``` ```js
let promise = radio.getPrimarySlotId(); let promise = radio.getPrimarySlotId();
promise.then(data => { promise.then(data => {
console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => { radio.getSignalInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getSignalInformation(slotId); let promise = radio.getSignalInformation(slotId);
promise.then(data => { promise.then(data => {
...@@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\). ...@@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\).
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let result = radio.isNrSupported(slotId); let result = radio.isNrSupported(slotId);
console.log(result); console.log(result);
...@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us ...@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Example** **Example**
``` ```js
radio.isRadioOn((err, data) => { radio.isRadioOn((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo ...@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.isRadioOn(slotId, (err, data) => { radio.isRadioOn(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t ...@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.isRadioOn(slotId); let promise = radio.isRadioOn(slotId);
promise.then(data => { promise.then(data => {
...@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r ...@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
radio.getOperatorName(slotId, (err, data) => { radio.getOperatorName(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result. ...@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = radio.getOperatorName(slotId); let promise = radio.getOperatorName(slotId);
promise.then(data => { promise.then(data => {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import sim from '@ohos.telephony.sim'; import sim from '@ohos.telephony.sim';
``` ```
...@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an ...@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an
**Example** **Example**
``` ```js
sim.isSimActive(0, (err, data) => { sim.isSimActive(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a ...@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a
**Example** **Example**
``` ```js
let promise = sim.isSimActive(0); let promise = sim.isSimActive(0);
promise.then(data => { promise.then(data => {
console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`); console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
...@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A ...@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example** **Example**
``` ```js
sim.getDefaultVoiceSlotId((err, data) => { sim.getDefaultVoiceSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A ...@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example** **Example**
``` ```js
let promise = sim.getDefaultVoiceSlotId(); let promise = sim.getDefaultVoiceSlotId();
promise.then(data => { promise.then(data => {
console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example** **Example**
``` ```js
sim.hasOperatorPrivileges(0, (err, data) => { sim.hasOperatorPrivileges(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example** **Example**
``` ```js
let promise = sim.hasOperatorPrivileges(0); let promise = sim.hasOperatorPrivileges(0);
promise.then(data => { promise.then(data => {
console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`); console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
...@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example** **Example**
``` ```js
sim.getISOCountryCodeForSim(0, (err, data) => { sim.getISOCountryCodeForSim(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example** **Example**
``` ```js
let promise = sim.getISOCountryCodeForSim(0); let promise = sim.getISOCountryCodeForSim(0);
promise.then(data => { promise.then(data => {
console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
...@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie ...@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
**Example** **Example**
``` ```js
sim.getSimOperatorNumeric(0, (err, data) => { sim.getSimOperatorNumeric(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi ...@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi
**Example** **Example**
``` ```js
let promise = sim.getSimOperatorNumeric(0); let promise = sim.getSimOperatorNumeric(0);
promise.then(data => { promise.then(data => {
console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
...@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T ...@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
**Example** **Example**
``` ```js
sim.getSimSpn(0, (err, data) => { sim.getSimSpn(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t ...@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t
**Example** **Example**
``` ```js
let promise = sim.getSimSpn(0); let promise = sim.getSimSpn(0);
promise.then(data => { promise.then(data => {
console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
...@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async ...@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async
**Example** **Example**
``` ```js
sim.getSimState(0, (err, data) => { sim.getSimState(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis ...@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis
**Example** **Example**
``` ```js
let promise = sim.getSimState(0); let promise = sim.getSimState(0);
promise.then(data => { promise.then(data => {
console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
...@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr ...@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr
**Example** **Example**
``` ```js
sim.getCardType(0, (err, data) => { sim.getCardType(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise ...@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise
**Example** **Example**
``` ```js
let promise = sim.getCardType(0); let promise = sim.getCardType(0);
promise.then(data => { promise.then(data => {
console.log(`getCardType success, promise: data->${JSON.stringify(data)}`); console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
...@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an ...@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Example** **Example**
``` ```js
sim.hasSimCard(0, (err, data) => { sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a ...@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a
**Example** **Example**
``` ```js
let promise = sim.hasSimCard(0); let promise = sim.hasSimCard(0);
promise.then(data => { promise.then(data => {
console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`); console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
...@@ -520,7 +520,7 @@ Obtains the number of card slots. ...@@ -520,7 +520,7 @@ Obtains the number of card slots.
**Example** **Example**
``` ```js
console.log(sim.getMaxSimCount()) console.log(sim.getMaxSimCount())
``` ```
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## Modules to Import ## Modules to Import
``` ```js
import sms from '@ohos.telephony.sms'; import sms from '@ohos.telephony.sms';
``` ```
...@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp ...@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
**Example** **Example**
``` ```js
const specification = '3gpp'; const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91]; const pdu = [0x08, 0x91];
...@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol. ...@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Example** **Example**
``` ```js
const specification = '3gpp'; const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91]; const pdu = [0x08, 0x91];
...@@ -91,7 +91,7 @@ Sends an SMS message. ...@@ -91,7 +91,7 @@ Sends an SMS message.
**Example** **Example**
``` ```js
let sendCallback = function (err, data) { let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
} }
...@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use ...@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example** **Example**
``` ```js
sms.getDefaultSmsSlotId((err, data) => { sms.getDefaultSmsSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use ...@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example** **Example**
``` ```js
let promise = sms.getDefaultSmsSlotId(); let promise = sms.getDefaultSmsSlotId();
promise.then(data => { promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
...@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => { sms.setSmscAddr(slotId, smscAddr, (err,data) => {
...@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr); let promise = sms.setSmscAddr(slotId, smscAddr);
...@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => { sms.getSmscAddr(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
...@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications.
**Example** **Example**
``` ```js
let slotId = 0; let slotId = 0;
let promise = sms.getSmscAddr(slotId); let promise = sms.getSmscAddr(slotId);
promise.then(data => { promise.then(data => {
...@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo ...@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo
| ------- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.| | boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
``` ```js
let result = sms.hasSmsCapability(); let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`); console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
``` ```
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## Modules to Import ## Modules to Import
``` ```js
import socket from '@ohos.net.socket'; import socket from '@ohos.net.socket';
``` ```
...@@ -28,7 +28,7 @@ Creates a **UDPSocket** object. ...@@ -28,7 +28,7 @@ Creates a **UDPSocket** object.
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
``` ```
...@@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1}); let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1});
promise .then(() => { promise .then(() => {
...@@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t ...@@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.send({ udp.send({
data:'Hello, server!', data:'Hello, server!',
...@@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re ...@@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.send({ let promise = udp.send({
data:'Hello, server!', data:'Hello, server!',
...@@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return ...@@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.close(err => { udp.close(err => {
if (err) { if (err) {
...@@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result. ...@@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.close(); let promise = udp.close();
promise.then(() => { promise.then(() => {
...@@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca ...@@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur ...@@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous ...@@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> {
if (err) { if (err) {
...@@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re ...@@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}); let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1});
promise.then(() => { promise.then(() => {
...@@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This ...@@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('message', value => { udp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi ...@@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback = value =>{ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke ...@@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('listening', () => { udp.on('listening', () => {
console.log("on listening success"); console.log("on listening success");
...@@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock ...@@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback1 = () =>{ let callback1 = () =>{
console.log("on listening, success"); console.log("on listening, success");
...@@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an ...@@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
udp.on('error', err => { udp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err)) console.log("on error, err:" + JSON.stringify(err))
...@@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a ...@@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a
**Example** **Example**
``` ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let callback = err =>{ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
...@@ -680,7 +680,7 @@ Creates a **TCPSocket** object. ...@@ -680,7 +680,7 @@ Creates a **TCPSocket** object.
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
``` ```
...@@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) { if (err) {
...@@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random ...@@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}); let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1});
promise.then(() => { promise.then(() => {
...@@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses ...@@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => { tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => {
if (err) { if (err) {
...@@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses ...@@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t ...@@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re ...@@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => { promise1.then(() => {
...@@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return ...@@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.close(err => { tcp.close(err => {
if (err) { if (err) {
...@@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result. ...@@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result.
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.close(); let promise = tcp.close();
promise.then(() => { promise.then(() => {
...@@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron ...@@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to ...@@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => { promise1.then(() => {
...@@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca ...@@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur ...@@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous ...@@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re ...@@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => { promise.then(() => {
...@@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This ...@@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('message', value => { tcp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo) console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo)
...@@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi ...@@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback = value =>{ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
...@@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th ...@@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('connect', () => { tcp.on('connect', () => {
console.log("on connect success") console.log("on connect success")
...@@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T ...@@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback1 = () =>{ let callback1 = () =>{
console.log("on connect success"); console.log("on connect success");
...@@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an ...@@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
tcp.on('error', err => { tcp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err)) console.log("on error, err:" + JSON.stringify(err))
...@@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a ...@@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a
**Example** **Example**
``` ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let callback = err =>{ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
......
...@@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a ...@@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a
## Modules to Import ## Modules to Import
``` ```js
import webSocket from '@ohos.net.webSocket'; import webSocket from '@ohos.net.webSocket';
``` ```
## Complete Example ## Complete Example
``` ```js
import webSocket from '@ohos.net.webSocket'; import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://"; var defaultIpAddress = "ws://";
...@@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc ...@@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
``` ```
...@@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL ...@@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke ...@@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, { ws.connect(url, {
...@@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke ...@@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
let promise = ws.connect(url); let promise = ws.connect(url);
...@@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac ...@@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the ...@@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.connect(url, (err, value) => { ws.connect(url, (err, value) => {
...@@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return ...@@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.close((err, value) => { ws.close((err, value) => {
...@@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** ...@@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
ws.close({ ws.close({
...@@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and ** ...@@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let url = "ws://" let url = "ws://"
let promise = ws.close({ let promise = ws.close({
...@@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us ...@@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => { ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message); console.log("on open, status:" + value.status + ", message:" + value.message);
...@@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u ...@@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
let callback1 = (err, value) => { let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message); console.log("on open, status:" + value.status + ", message:" + value.message);
...@@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API ...@@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('message', (err, value) => { ws.on('message', (err, value) => {
console.log("on message, message:" + value); console.log("on message, message:" + value);
...@@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP ...@@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('message'); ws.off('message');
``` ```
...@@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u ...@@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => { ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason); console.log("on close, code is " + value.code + ", reason is " + value.reason);
...@@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API ...@@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('close'); ws.off('close');
``` ```
...@@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u ...@@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.on('error', (err) => { ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err)) console.log("on error, error:" + JSON.stringify(err))
...@@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API ...@@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API
**Example** **Example**
``` ```js
let ws = webSocket.createWebSocket(); let ws = webSocket.createWebSocket();
ws.off('error'); ws.off('error');
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册