本演示项目在Unity for Android Build中启用部分华为HMS和AGC服务,对应的类和函数的名称和用法相同。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

8.0 KiB

HuaweiService.appmessage

Scenario: Message event callback消息事件回调

Description Api Reference
Callback for a message tap.
点击事件回调
AGConnectAppMessagingOnClickListener.onMessageClick(AppMessage appMessage) AGConnectAppMessagingOnClickListener

Example
Callback for message closing.
消息消失回调
AGConnectAppMessagingOnDismissListener.onMessageDismiss(AppMessage appMessage, AGConnectAppMessagingCallback.DismissType dismissType) AGConnectAppMessagingOnDismissListener

Example
Callback for message display.
消息展示回调
AGConnectAppMessagingOnDisplayListener.onMessageDisplay(AppMessage appMessage) AGConnectAppMessagingOnDisplayListener

Example

Scenario: Message processing callback (custom display interface must call back this interface)消息处理回调(自定义显示界面必须回调此接口)

Description Api Reference
Callback for a message tap.
消息被点击时回调
AGConnectAppMessagingCallback.onMessageClick(AppMessage appMessage) AGConnectAppMessagingCallback

Example
Callback for message closing.
消息消失时回调
AGConnectAppMessagingCallback.onMessageDismiss(AppMessage appMessage, AGConnectAppMessagingCallback.DismissType dismissType) AGConnectAppMessagingCallback

Example
Callback for message display. If you need to customize your message layout, you must call this method. Otherwise, whether your message has been actually displayed cannot be determined, and the message will be displayed repeatedly.
消息展示时回调。自定义消息显示界面时该方法必须回调,否则无法确定消息是否真实显示,导致消息会重复显示
AGConnectAppMessagingCallback.onMessageDisplay(AppMessage appMessage) AGConnectAppMessagingCallback

Example
Callback for message image loading exceptions.
消息图片加载异常时回调
AGConnectAppMessagingOnErrorListener.onMessageError(AppMessage appMessage) AGConnectAppMessagingOnErrorListener

Example
Checks whether the App Messaging SDK is allowed to synchronize in-app message data from the AppGallery Connect server.
同步AGC服务端消息控制
AGConnectAppMessaging.isFetchMessageEnable()/AGConnectAppMessaging.setFetchMessageEnable(boolean enable) AGConnectAppMessaging

Example
Checks whether the App Messaging SDK is allowed to display in-app messages.
消息展示控制
AGConnectAppMessaging.isDisplayEnable()/AGConnectAppMessaging.setDisplayEnable(boolean enable) AGConnectAppMessaging

Example
Sets the forcible in-app message data obtaining flag. When the flag is enabled, you can obtain latest in-app message data from the AppGallery Connect server in real time.
设置强制请求AGC服务端数据的标记位
AGConnectAppMessaging.setForceFetch() AGConnectAppMessaging

Example

Scenario: Custom message layout control自定义消息布局控制

Description Api Reference
Adds a custom in-app message layout. You can call this method to add a custom layout to implement personalized message display. If this method is not called, the default layout is used.
添加消息展示的自定义布局
AGConnectAppMessaging.addCustomView(AGConnectAppMessagingDisplay display) AGConnectAppMessaging

Example
Deletes a custom in-app message layout. Then the default layout will be used.
移除开发者添加的自定义显示布局
AGConnectAppMessaging.removeCustomView() AGConnectAppMessaging

Example
Sets the display position of a pop-up or image message.
设置图片和弹框消息的显示位置
AGConnectAppMessaging.setDisplayLocation(Location location) AGConnectAppMessaging

Example
Triggers a custom event.
触发自定义事件
AGConnectAppMessaging.trigger(String eventId) AGConnectAppMessaging

Example