tencent cloud

Feedback

Customizing Plugin Capabilities

Last updated: 2024-08-06 15:44:43
You can associate the data interaction between the mini program and the host app by implementing the OpenApiHandler and TcmppPlatformEventHandler abstract classes.
Sample code:
_tcmppFlutterPlugin.registerOpenApiHandler(MyOpenApiHandler());
_tcmppFlutterPlugin.registerPlatformEventHandler(MyPlatformHandler());
Sample code for API class implementation:
class MyPlatformHandler extends TcmppPlatformEventHandler {
@override
Future<List<CustomMenu>> getCustomMenus() async {
CustomMenu menu1 = CustomMenu(
'100', 'res/images/mini_app_wechat_friend.png', 'Share To', true,
shareKey: 'twitter');
CustomMenu menu2 = CustomMenu(
'101',
'https://staticintl.cloudcachetci.com/cms/backend-cms/8WGP653_%E5%BC%80%E5%8F%91%E8%80%85%E5%B7%A5%E5%85%B7%E9%80%9A%E7%94%A8.png',
'Custom',
false);
return [
menu1,
menu2,
];
}
@override
Future<void> customMenuClick(String menuId, ShareData? shareMenu) async {
print("click menuId:$menuId shareMenu:$shareMenu");
throw UnimplementedError();
}
@override
Future<bool> reportEvent(int eventId, String eventName, AppInfo appInfo,
Map<Object?, Object?> params) async {
print("reportEvent:$eventName appinfo:$appInfo params:$params");
// TODO: implement reportEvent
return true;
}
@override
Future<void> onMiniProgramStateChange(
String appId, MiniProgramState state) async {
print("app state change: appid=$appId, state=$state");
}
}

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support