RemoteLocationExtensionAbility is currently in the beta test phase and not open for application.
RemoteLocationExtensionAbility provides callbacks for obtaining location-specific message data and destroying the lifecycle. After a user grants the location permission, RemoteLocationExtensionAbility can query the user's location and push messages based on service requirements. The restrictions are as follows:
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Push.PushService
Start version: 4.1.0(11)
Model restriction: The attributes can be used only in the stage model.
System capability: SystemCapability.Push.PushService
Start version: 4.1.0(11)
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
context | No | No | Context of RemoteLocationExtensionAbility, which inherits from ExtensionContext. |
onReceiveMessage(payload: pushCommon.PushPayload): Promise<void>
API for receiving scenario-specific messages after an app inherits from RemoteLocationExtensionAbility. This API returns the result asynchronously through a promise.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Push.PushService
Start version: 4.1.0(11)
Parameters:
Parameter | Type | Optional | Description |
|---|---|---|---|
payload | pushCommon.PushPayload | No | Scenario-specific message data. |
Returns:
Type | Description |
|---|---|
Promise<void> | Promise object. No result is returned. |
Example:
import { RemoteLocationExtensionAbility, pushCommon } from '@kit.PushKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
// In the following example, TestExtAbility inherits from RemoteLocationExtensionAbility:
export default class TestExtAbility extends RemoteLocationExtensionAbility {
async onReceiveMessage(payload: pushCommon.PushPayload): Promise<void> {
hilog.info(0x0000, 'testTag', 'TestExtAbility onReceiveMessage, payload : %{public}s', JSON.stringify(payload));
}
} onDestroy(): void
This callback is executed when the RemoteLocationExtensionAbility lifecycle ends. You are advised to clear resources in this method.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Push.PushService
Start version: 4.1.0(11)
Example:
import { RemoteLocationExtensionAbility } from '@kit.PushKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
// In the following example, TestExtAbility inherits from RemoteLocationExtensionAbility:
export default class TestExtAbility extends RemoteLocationExtensionAbility {
onDestroy(): void {
hilog.info(0x0000, 'testTag', 'TestExtAbility onDestroy');
}
}