Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CrashService

Hierarchy

  • CrashService

Index

Methods

enableCrashCollection

  • enableCrashCollection(enable: boolean): void
  • en

    This method is used to enable or disable the crash data reporting function. The function is enabled by default, indicating that the Crash service will collect and report crash data. If you do not want the Crash service to automatically collect or report crash data, disable the function.

    zh

    是否开启崩溃服务,默认开启。开启时崩溃服务将会收集和上报崩溃信息。如果不需要使用崩溃服务,设置为关闭即可。

    example
    huawei.agc.crash.CrashService.enableCrashCollection(false);
    

    Parameters

    • enable: boolean

      Indicates whether to enable the crash data reporting function.

    Returns void

log

  • log(level: LOG, content: string): void
  • en

    Records a custom log.

    zh

    设置自定义日志。

    example
    huawei.agc.crash.crashService.log(huawei.agc.crash.LOG.DEBUG, 'debug log invoke');
    

    Parameters

    • level: LOG

      Custom log level, Log.DEBUG/Log.INFO/Log.WARN/Log.ERROR levels are supported.

    • content: string

      Custom log content. The length of a single log cannot exceed 4 KB. An overlong log will be truncated. The total size of logs cannot exceed 64 KB. If the upper limit is exceeded, earliest logs will be deleted.

    Returns void

off

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

    remove event listener

    zh

    取消事件的监听

    Parameters

    • event_name: string

      event name

    • callback: Function

      callback function

    • target: any

      target node

    Returns void

on

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

    event listener

    zh

    持续监听事件

    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
  • en

    event listener for once

    zh

    监听一次事件

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

setCustomKey

  • setCustomKey(key: string, value: any): void
  • zh

    设置自定义键值对的 key 和 value. value 可为 boolean/string/number/float 类型。

    en

    Sets a custom key-value pair. The value can be boolean/string/number/float type.

    example
    huawei.agc.crash.crashService.setCustomKey('floatKey123', 123.11);
    huawei.agc.crash.crashService.setCustomKey('intKey123', 123);
    huawei.agc.crash.crashService.setCustomKey('stringKey123', 'crash');
    huawei.agc.crash.crashService.setCustomKey('booleanKey123', true);
    

    Parameters

    • key: string

      Key of the custom key-value pair. The maximum length of each key is 1 KB. An overlong key will be truncated. A maximum of 64 key-value pairs are supported, and the excessive part will not be saved.

    • value: any

      Value of the custom key-value pair. The maximum length of each value is 1 KB. An overlong value will be truncated. A maximum of 64 key-value pairs are supported, and the excessive part will not be saved.

    Returns void

setUserId

  • setUserId(userId: string): void
  • en

    Sets a custom user ID.

    zh

    设置自定义用户标识符

    example
    huawei.agc.crash.crashService.setUserId('user001');
    

    Parameters

    • userId: string

      Unique anonymous identifier generated for a user based on an algorithm. The maximum length is 1 KB. An overlong value will be truncated. If you want to delete a user ID, reset the parameter to an empty string. Deleting a user ID will not delete the crash records of the ID.

    Returns void

targetOff

  • targetOff(target_node: any): void
  • en

    remove all event listener for the node

    zh

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

    Parameters

    • target_node: any

    Returns void

testIt

  • testIt(): void
  • en

    This method is used to trigger a crash for testing an app. This method can be used to test the Crash service of your app during debugging. Do not use it in any formally released app.

    zh

    此方法用于创造测试用的崩溃。仅供开发者在测试崩溃实现时使用,正式发布的应用中请勿使用

    example
    huawei.agc.crash.CrashService.testIt();
    

    Returns void

Static callStaticMethod

  • callStaticMethod(...args: any[]): void
  • en

    call function from java side

    zh

    调用到 java 层的通用函数

    Parameters

    • Rest ...args: any[]

    Returns void

Generated using TypeDoc