提交 a2b306ab 编写于 作者: E ester.zhou

Update docs (13343)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 06e934c6
# @ohos.notificationSubscribe
# @ohos.notificationSubscribe (NotificationSubscribe)
The **NotificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs.
The **notificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs.
> **NOTE**
>
......@@ -9,7 +9,7 @@ The **NotificationSubscribe** module provides APIs for notification subscription
## Modules to Import
```js
import NotificationSubscribe from '@ohos.notificationSubscribe';
import notificationSubscribe from '@ohos.notificationSubscribe';
```
......@@ -56,17 +56,15 @@ function subscribeCallback(err) {
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
}
var info = {
};
let info = {
bundleNames: ["bundleName1","bundleName2"]
}
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback);
};
notificationSubscribe.subscribe(subscriber, info, subscribeCallback);
```
## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
......@@ -107,10 +105,10 @@ function subscribeCallback(err) {
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
}
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
......@@ -148,10 +146,10 @@ Subscribes to a notification with the subscription information specified. This A
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
};
NotificationSubscribe.subscribe(subscriber).then(() => {
notificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe success");
});
```
......@@ -198,14 +196,12 @@ function unsubscribeCallback(err) {
function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onDisconnect: onDisconnectCallback
}
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
};
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
......@@ -238,16 +234,14 @@ Unsubscribes from a notification. This API uses a promise to return the result.
function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data));
}
var subscriber = {
let subscriber = {
onDisconnect: onDisconnectCallback
};
NotificationSubscribe.unsubscribe(subscriber).then(() => {
notificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe success");
});
```
## NotificationSubscribe.remove
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
......@@ -289,15 +283,15 @@ function removeCallback(err) {
console.info("remove success");
}
}
var bundle = {
let bundle = {
bundle: "bundleName1",
}
var notificationKey = {
};
let notificationKey = {
id: 0,
label: "label",
}
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
};
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
```
......@@ -335,21 +329,19 @@ Removes a notification for a specified application. This API uses a promise to r
**Example**
```js
var bundle = {
let bundle = {
bundle: "bundleName1",
}
var notificationKey = {
};
let notificationKey = {
id: 0,
label: "label",
}
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
};
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success");
});
```
## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
......@@ -382,7 +374,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
**Example**
```js
var hashCode = 'hashCode'
let hashCode = 'hashCode';
function removeCallback(err) {
if (err) {
......@@ -391,12 +383,10 @@ function removeCallback(err) {
console.info("remove success");
}
}
var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback);
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason, removeCallback);
```
## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason): Promise\<void\>
......@@ -428,15 +418,13 @@ Removes a specified notification. This API uses a promise to return the result.
**Example**
```js
var hashCode = 'hashCode'
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => {
let hashCode = 'hashCode';
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success");
});
```
## NotificationSubscribe.removeAll
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
......@@ -475,14 +463,12 @@ function removeAllCallback(err) {
console.info("removeAll success");
}
}
var bundle = {
let bundle = {
bundle: "bundleName1",
}
};
NotificationSubscribe.removeAll(bundle, removeAllCallback);
```
## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback\<void\>): void
......@@ -520,11 +506,9 @@ function removeAllCallback(err) {
}
}
NotificationSubscribe.removeAll(removeAllCallback);
notificationSubscribe.removeAll(removeAllCallback);
```
## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise\<void\>
......@@ -556,7 +540,7 @@ Removes all notifications for a specified application. This API uses a promise t
```js
// If no application is specified, notifications of all applications are deleted.
NotificationSubscribe.removeAll().then(() => {
notificationSubscribe.removeAll().then(() => {
console.info("removeAll success");
});
```
......@@ -600,9 +584,9 @@ function removeAllCallback(err) {
}
}
var userId = 1
let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback);
notificationSubscribe.removeAll(userId, removeAllCallback);
```
## Notification.removeAll
......@@ -643,13 +627,11 @@ function removeAllCallback(err) {
}
}
var userId = 1
let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback);
notificationSubscribe.removeAll(userId, removeAllCallback);
```
## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
......@@ -689,11 +671,11 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id);
};
var subscriber = {
let subscriber = {
onConsume: onConsumeCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
......@@ -729,11 +711,11 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id);
}
var subscriber = {
let subscriber = {
onCancel: onCancelCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
......@@ -767,11 +749,11 @@ function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
var subscriber = {
let subscriber = {
onUpdate: onUpdateCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
......@@ -799,11 +781,11 @@ function onConnectCallback() {
console.info('===> onConnect in test');
}
var subscriber = {
let subscriber = {
onConnect: onConnectCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
......@@ -841,15 +823,15 @@ function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
var subscriber = {
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
......@@ -877,11 +859,11 @@ function onDestroyCallback() {
console.info('===> onDestroy in test');
}
var subscriber = {
let subscriber = {
onDestroy: onDestroyCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange
......@@ -915,11 +897,11 @@ function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
var subscriber = {
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
......@@ -956,11 +938,11 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: ", callbackData.enable);
};
var subscriber = {
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
NotificationSubscribe.subscribe(subscriber, subscribeCallback);
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## BundleOption
......@@ -1011,7 +993,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
## NotificationSorting
Provides sorting information of activity notifications.
Provides sorting information of active notifications.
**System capability**: SystemCapability.Notification.Notification
......
......@@ -3,13 +3,14 @@
The **device** module provides APIs for checking information about the current device.
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [@ohos.deviceInfo](js-apis-device-info.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```typescript
import device from '@system.device';
```
......@@ -39,14 +40,14 @@ Obtains the device information.
| -------- | -------- | -------- |
| brand | string | Brand.|
| manufacturer | string | Manufacturer.|
| model | string | Model. |
| model | string | Model.|
| product | string | Product number.|
| language<sup>4+</sup> | string | System language.|
| region<sup>4+</sup> | string | System region.|
| windowWidth | number | Window width.|
| windowHeight | number | Window height.|
| screenDensity<sup>4+</sup> | number | Screen density.|
| screenShape<sup>4+</sup> | string | Screen shape. The options are as follows:<br>- **rect**: rectangle screen<br>- **circle**: circle screen|
| screenShape<sup>4+</sup> | string | Screen shape. The options are as follows:<br>- **rect**: rectangular screen<br>- **circle**: round screen|
| apiVersion<sup>4+</sup> | number | API version.|
| releaseType<sup>4+</sup> | string | Release type. The value includes both the release type and the API version, for example, Beta1.<br>Available release types are as follows:<br>- **Canary**: For the same API version, different canary releases are compatible with each other, but not compatible with those of the **beta** and **release** type.<br>- **Beta**: For the same API version, different beta releases are compatible with each other, but not compatible with those of the **release** type.<br>- **Release**: Releases of this type are compatible with the latest five API versions.|
| deviceType<sup>4+</sup> | string | Device type.|
......@@ -55,11 +56,11 @@ Obtains the device information.
| Error Code| Description|
| -------- | -------- |
| 200 | The returned result contains information that cannot be obtained.|
| 200 | Certain information cannot be obtained.|
**Example**
```
```typescript
export default {
getInfo() {
device.getInfo({
......
# @system.notification
# @system.notification (Notification)
> **NOTE**
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.notification`](js-apis-notification.md).
......@@ -9,7 +9,7 @@
## Modules to Import
```
```ts
import notification from '@system.notification';
```
......@@ -59,9 +59,9 @@ export default {
clickAction: {
bundleName: 'com.example.testapp',
abilityName: 'notificationDemo',
uri: '/path/to/notification',
},
uri: '/path/to/notification'
}
});
},
}
}
```
......@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object.
// Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200)
var gradient = ctx.createRadialGradient(200,200,50, 200,200,200);
// Add three color stops
gradient.addColorStop(0.0, 'red');
gradient.addColorStop(0.5, 'white');
gradient.addColorStop(1.0, 'green');
gradient.addColorStop(0.0, '#ff0000');
gradient.addColorStop(0.5, '#ffffff');
gradient.addColorStop(1.0, '#00ff00');
// Set the fill style and draw a rectangle
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 500, 500);
......
......@@ -773,7 +773,7 @@ Clears the content in a rectangle on the canvas.
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffffff')
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(20,20,200,200)
......@@ -1583,7 +1583,7 @@ struct Fill {
region.lineTo(270, 90)
region.closePath()
// Fill path
this.context.fillStyle = 'green'
this.context.fillStyle = '#00ff00'
this.context.fill(region, "evenodd")
})
}
......@@ -1749,7 +1749,7 @@ Rotates a canvas clockwise around its coordinate axes.
.height('100%')
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees
this.context.rotate(45 * Math.PI / 180)
this.context.fillRect(70, 20, 50, 50)
})
}
......@@ -2417,7 +2417,7 @@ Restores the saved drawing context.
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.save() // save the default state
this.context.fillStyle = "green"
this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100)
......@@ -2455,7 +2455,7 @@ Saves all states of the canvas in the stack. This API is usually called when the
.backgroundColor('#ffff00')
.onReady(() =>{
this.context.save() // save the default state
this.context.fillStyle = "green"
this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100)
......@@ -2502,9 +2502,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00')
.onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100)
grad.addColorStop(0.0, 'red')
grad.addColorStop(0.5, 'white')
grad.addColorStop(1.0, 'green')
grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500)
})
......@@ -2553,9 +2553,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00')
.onReady(() =>{
var grad = this.context.createRadialGradient(200,200,50, 200,200,200)
grad.addColorStop(0.0, 'red')
grad.addColorStop(0.5, 'white')
grad.addColorStop(1.0, 'green')
grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500)
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册