js-apis-application-staticSubscriberExtensionAbility.md 1.8 KB
Newer Older
1
# @ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)
W
wusongqing 已提交
2

3 4
The **StaticSubscriberExtensionAbility** module provides Extension abilities for static subscribers.

W
wusongqing 已提交
5
> **NOTE**
6
>
E
ester.zhou 已提交
7
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
>
W
wusongqing 已提交
9
> The APIs of this module can be used only in the stage model.
W
wusongqing 已提交
10 11
## Modules to Import

12
```ts
13
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
W
wusongqing 已提交
14 15
```

G
Gloria 已提交
16 17
## Attributes

E
ester.zhou 已提交
18 19 20
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**System API**: This is a system API and cannot be called by third-party applications.
G
Gloria 已提交
21 22 23

| Name   | Type                                                        | Readable| Writable| Description    |
| ------- | ------------------------------------------------------------ | ---- | ---- | -------- |
E
ester.zhou 已提交
24
| context<sup>10+</sup> | [StaticSubscriberExtensionContext](js-apis-application-StaticSubscriberExtensionContext.md) | Yes  | No  | Context.|
G
Gloria 已提交
25

W
wusongqing 已提交
26 27 28 29 30 31
## StaticSubscriberExtensionAbility.onReceiveEvent

onReceiveEvent(event: CommonEventData): void;

Callback of the common event of a static subscriber.

32 33 34
**System capability**: SystemCapability.Ability.AbilityRuntime.Core

**System API**: This is a system API and cannot be called by third-party applications.
W
wusongqing 已提交
35 36 37

**Parameters**

38 39
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
40
| event | [CommonEventData](js-apis-commonEventManager.md#commoneventdata) | Yes| Common event of a static subscriber.|
W
wusongqing 已提交
41

42
**Example**
43
  ```ts
44 45 46 47 48
    class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
        onReceiveEvent(event) {
            console.log('onReceiveEvent, event: ${JSON.stringify(event)}');
        }
    }
W
wusongqing 已提交
49
  ```