# HuaweiService.appmessage
#### Scenario: Message event callback``消息事件回调``
| Description | Api | Reference |
---|---|---
Callback for a message tap.
``点击事件回调``|AGConnectAppMessagingOnClickListener.onMessageClick(AppMessage appMessage) |[AGConnectAppMessagingOnClickListener](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingOnClickListener)
[Example](https://github.com/Unity-Technologies/HMSSDKSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L56)
Callback for message closing.
``消息消失回调``|AGConnectAppMessagingOnDismissListener.onMessageDismiss(AppMessage appMessage, AGConnectAppMessagingCallback.DismissType dismissType)|[AGConnectAppMessagingOnDismissListener](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingOnDismissListener)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L29)
Callback for message display.
``消息展示回调``|AGConnectAppMessagingOnDisplayListener.onMessageDisplay(AppMessage appMessage) |[AGConnectAppMessagingOnDisplayListener](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingOnDisplayListener)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L39)
#### 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](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingCallback)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L56)
Callback for message closing.
``消息消失时回调``|AGConnectAppMessagingCallback.onMessageDismiss(AppMessage appMessage, AGConnectAppMessagingCallback.DismissType dismissType)|[AGConnectAppMessagingCallback](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingCallback)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L56)
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](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingCallback)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L56)
Callback for message image loading exceptions.
``消息图片加载异常时回调``|AGConnectAppMessagingOnErrorListener.onMessageError(AppMessage appMessage)|[AGConnectAppMessagingOnErrorListener](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessagingOnErrorListener)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageListener.cs#L56)
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](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L59)
Checks whether the App Messaging SDK is allowed to display in-app messages.
``消息展示控制``|AGConnectAppMessaging.isDisplayEnable()/AGConnectAppMessaging.setDisplayEnable(boolean enable) |[AGConnectAppMessaging](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L46)
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](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L72)
#### 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](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L106)
Deletes a custom in-app message layout. Then the default layout will be used.
``移除开发者添加的自定义显示布局``|AGConnectAppMessaging.removeCustomView()|[AGConnectAppMessaging](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L113)
Sets the display position of a pop-up or image message.
``设置图片和弹框消息的显示位置``|AGConnectAppMessaging.setDisplayLocation(Location location)|[AGConnectAppMessaging](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L119)
Triggers a custom event.
``触发自定义事件``|AGConnectAppMessaging.trigger(String eventId)|[AGConnectAppMessaging](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/AGConnectAppMessaging)
[Example](https://github.com/Unity-Technologies/HuaweiServiceSample/blob/8a72eb9b34a2d6f1cfe3a8d3340dbf2c6ae1eb4b/Assets/HuaweiServiceDemo/Scripts/test/appmessage/AppMessageTest.cs#L125)