Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AppMessagingService

Hierarchy

  • AppMessagingService

Index

Methods

emit

  • emit(event_name: string, ...params: any[]): void
  • zh

    发送事件

    Parameters

    • event_name: string

      event name

    • Rest ...params: any[]

      event parameters

    Returns void

getAAID

  • getAAID(): string
  • en

    get AAID, synchronization method

    zh

    获取 AAID,同步方法

    example
    console.log('current AAID = ', huawei.agc.appmessaging.appMessagingService.getAAID());
    

    Returns string

    AAID

isDisplayEnable

  • isDisplayEnable(): boolean
  • en

    Checks whether to allow the App Messaging SDK to display in-app messages

    zh

    获取是否允许显示消息

    example
    console.log('isDisplayEnable', huawei.agc.appmessaging.appMessagingService.isDisplayEnable());
    

    Returns boolean

    Indicates whether to allow the App Messaging SDK to display in-app messages.

isFetchMessageEnable

  • isFetchMessageEnable(): boolean
  • en

    Checks whether to allow the App Messaging SDK to synchronize in-app message data from the AppGallery Connect server

    zh

    获取是否允许App Messaging SDK 同步 AGC 服务端的消息

    example
    console.log('isFetchMessageEnable = ', huawei.agc.appmessaging.appMessagingService.isFetchMessageEnable());
    

    Returns boolean

    Indicates whether to allow the App Messaging SDK to synchronize in-app message data from the AppGallery Connect server.

off

  • off(event_name: string, callback: Function, target: any): void
  • zh

    取消事件的监听

    example
    huawei.agc.appmessaging.appMessagingService.off(huawei.agc.appmessaging.AGC_APP_MESSAGING_LISTENER_NAME.ON_MESSAGE_DISMISS, (result) => {}, this);
    

    Parameters

    • event_name: string

      event name

    • callback: Function

      callback function

    • target: any

      node

    Returns void

on

  • on(event_name: string, cb: Function, node?: any): void
  • zh

    持续监听事件

    example
    huawei.agc.appmessaging.appMessagingService.on(huawei.agc.appmessaging.AGC_APP_MESSAGING_LISTENER_NAME.ON_MESSAGE_DISMISS, (result) => {
        this.console.log('receive ON_MESSAGE_DISMISS', JSON.stringify(result));
    }, this);
    

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

once

  • once(event_name: string, cb: Function, node?: any): void
  • zh

    监听一次事件

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

      huawei.agc.appmessaging.appMessagingService.once(huawei.agc.appmessaging.AGC_APP_MESSAGING_LISTENER_NAME.ON_MESSAGE_DISMISS, (result) => {
          this.console.log('receive ON_MESSAGE_DISMISS', JSON.stringify(result));
      }, this);
      

    Returns void

removeCustomView

  • removeCustomView(): any
  • en

    Deletes a custom in-app message layout. Then the default layout will be used.

    zh

    移除开发者添加的自定义的显示布局,消息将会以默认的布局来展示。

    example
    huawei.agc.appmessaging.appMessagingService.removeCustomView();
    

    Returns any

setDisplayEnable

  • setDisplayEnable(enable: boolean): void
  • en

    Sets whether to allow the App Messaging SDK to display in-app messages.

    zh

    设置是否允许消息被展示

    example
    huawei.agc.appmessaging.appMessagingService.setDisplayEnable(true);
    

    Parameters

    • enable: boolean

      Indicates whether to allow the App Messaging SDK to display in-app messages. The default value is true.

    Returns void

setDisplayLocation

  • setDisplayLocation(location: Location): void
  • en

    Sets the display position of a pop-up or image message.

    zh

    设置图片和弹框消息的显示位置。

    example
    huawei.agc.appmessaging.appMessagingService.setDisplayLocation(huawei.agc.appmessaging.Location.BOTTOM);
    

    Parameters

    • location: Location

      Location instance. Currently, a pop-up or image message can be displayed in the center or at the bottom.

    Returns void

setFetchMessageEnable

  • setFetchMessageEnable(enable: boolean): void
  • en

    Sets whether to allow the App Messaging SDK to synchronize in-app message data from the AppGallery Connect server.

    zh

    设置是否允许 App Messaging SDK 同步 AGC 服务端的消息

    example
    huawei.agc.appmessaging.appMessagingService.setFetchMessageEnable(true);
    

    Parameters

    • enable: boolean

      Indicates whether to allow the App Messaging SDK to synchronize in-app message data from the AppGallery Connect server. The options are as follows:

      • true: yes
      • false: no The default value is true.

    Returns void

setForceFetch

  • setForceFetch(): void
  • en

    Sets the flag for whether to obtain in-app message data from the AppGallery Connect server in real time by force. After this method is called, the App Messaging SDK does not immediately request data from the AppGallery Connect server. When the next trigger event takes place, the App Messaging SDK forcibly obtains in-app message data from the AppGallery Connect server. The setForceFetch API can be used only for message testing. The forcible data obtaining flag is bound to the AAID of the test device. After you uninstall and reinstall the app or clear app data on the device, the flag will be reset.

    zh

    设置强制请求 AGC 云端消息数据的标记位。 调用此方法后 App Messaging SDK 不会立刻请求 AGC 服务端数据,等下一次消息事件触发时 App Messaging SDK 会强制从 AGC 服务端获取消息数据。 setForceFetch 方法仅作为调测消息使用,开发者在正式的版本中不能调用该接口setForceFetch 次数与设备的 AAID 绑定,开发者卸载应用重装或者清除应用数据后,forceFetch 标记位状态会重置。

    example
    huawei.agc.appmessaging.appMessagingService.setForceFetch();
    

    Returns void

targetOff

  • targetOff(target_node: any): void
  • zh

    取消某个节点所有的事件监听

    example
    huawei.agc.appmessaging.appMessagingService.targetOff(this);
    

    Parameters

    • target_node: any

    Returns void

trigger

  • trigger(eventId: string): void
  • en

    Triggers a custom event.

    zh

    触发自定义的事件

    example
    huawei.agc.appmessaging.appMessagingService.trigger(eventId);
    

    Parameters

    • eventId: string

      ID of a custom event.

    Returns void

Static callStaticMethod

  • callStaticMethod(...args: any[]): any
  • zh

    调用 java 层反射的方法

    Parameters

    • Rest ...args: any[]

    Returns any

Generated using TypeDoc