APIs | Plugin name | Permissions needed |
LBS related APIs (Location & POI search) | Access location | |
MDNS APIs | Access locale network | |
TCP/UDP APIs | Access internet | |
Meida APIs (Photos & Videos) | Access photo library | |
Wifi APIs, Bluetooth APIs, Calendar APIs, Contact APIs, Clipboard APIs, Biometric authentication APIs | Access wifi state, Access bluetooth, Access Calendar, Access contact, Access clipboard, Access fingerprint & face id | |
Map APIs | Access location |
Plugin name | Permission key |
tcmpp_flutter_lbs | NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription NSLocationUsageDescription NSMotionUsageDescription |
tcmpp_flutter_mdns | NSBonjourServices |
tcmpp_flutter_network | NSAppTransportSecurity |
tcmpp_flutter_media | NSPhotoLibraryUsageDescription NSCameraUsageDescription |
tcmpp_flutter_device | NSCalendarsUsageDescription NSRemindersUsageDescription
NSContactsUsageDescription NSFaceIDUsageDescription NSBluetoothAlwaysUsageDescription NSBluetoothPeripheralUsageDescription |
Field name | Type | Description |
configAssetsName | string | TCMPP android configuration file path |
debug | bool | enable SDK debugging & log |
enableX5Core | bool | Whether to use TBS service(X5 core) as mini-program runtime |
x5LicenseKey | string | License for TBS service if runtime enabled |
X5DocLicenseKey | string | License for TBS document service if runtime enabled |
x5Core32Url | string | Download url for 32-bit TBS runtime |
x5Core64Url | string | Download url for 64-bit TBS runtime |
Field name | Type | Description |
configAssetsName | string | TCMPP iOS configuration file path |
debug | bool | enable SDK debug |
logEnable | bool | enable SDK log |
inspectableEnabled | bool | Enable inspectable after iOS 16.4, you can debug mini-program through safari |
Field name | Type | Description |
appName | string | Host app name, mainly used for copyright prompts in mini-program |
appVersion | string | Host app version, mainly used for copyright prompts in mini-program |
minSdkVersion 21
ndk { abiFilters "armeabi", "armeabi-v7a", "arm64-v8a" }
packagingOptions {pickFirst 'lib/arm64-v8a/libc++_shared.so'pickFirst 'lib/armeabi/libc++_shared.so'pickFirst 'lib/armeabi-v7a/libc++_shared.so'pickFirst 'lib/arm64-v8a/libmarsxlog.so'pickFirst 'lib/armeabi/libmarsxlog.so'pickFirst 'lib/armeabi-v7a/libmarsxlog.so'pickFirst 'lib/arm64-v8a/libv8jni.so'}
source 'https://e.coding.net/tcmpp-work/tcmpp/tcmpp-repo.git'
pod install
class MyAppletHandler extends OpenApiHandler {@overrideFuture<Map<String, dynamic>> getUserProfile(AppInfo appInfo, Map<Object?, Object?> params) async {print("getUserProfile:$appInfo params:$params");Map<String, dynamic> result = {"userInfo": {"nickName": "xcode","avatarUrl":"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","gender": 1,"country": "China","province": "ChongQing","city": "ChongQing",}};return result;}@overrideFuture<Map<String, dynamic>> login(AppInfo appInfo, Map<Object?, Object?> params) async {/// return current login certification or do login if not logged in...}@overrideFuture<Map<String, dynamic>> checkSession(AppInfo appInfo, Map<Object?, Object?> params) async {/// throw any error if this api call is failedthrow NotLoggedInError();}/// other api implementation...}
final _tcmppFlutterPlugin = TcmppFlutter();...@overridevoid initState() {super.initState();.../// Must registered before mini-program is launched_tcmppFlutterPlugin.registerOpenApiHandler(MyAppletHandler());}
example code: /// Mini Program Callvar opts = {api_name: 'myApiName',success: function(res) {log(res);},fail: function(res) {log(res);},complete: function(res) {log(res);},data: {name : 'kka',age : 22}}wx.invokeNativePlugin(opts);
void initState() {super.initState();getRecentMini();/// Register custom JSAPI names and functions_tcmppFlutterPlugin.registerMiniAppApi("myApiName",myApiHandler);}/// Custom APIFuture<Map<String, dynamic>?> myApiHandler(MiniApiCall call) async {print("API : ${call.apiName}");print("AppInfo: ${call.appInfo}");print("WebView ID: ${call.webViewId}");print("params: ${call.params}");return {"result": "success","method":"myApiHandler"};}
class MyPlatformHandler extends TcmppPlatformEventHandler {@overrideFuture<void> onMiniProgramStateChange(String appId, MiniProgramState state) async {print("app state change: appid=$appId, state=$state");}/// other event handler implementation...}
final _tcmppFlutterPlugin = TcmppFlutter();...@overridevoid initState() {super.initState();.../// Must registered before mini-program is launched_tcmppFlutterPlugin.registerPlatformEventHandler(MyPlatformHandler());}
@overrideFuture<List<CustomMenu>> getCustomMenus() async {/// The menu includes menuId, picture (supports local path and network picture), menu name, and whether it is a custom sharing type.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,];}
@overrideFuture<void> customMenuClick(String menuId, ShareData? shareMenu) async {/// callback for menu button clickprint("click menuId:$menuId shareMenu:$shareMenu");throw UnimplementedError();}
@overrideFuture<void> onMiniProgramStateChange(String appId, MiniProgramState state) async {print("app state change: appid=$appId, state=$state");}
@overrideFuture<void> log(String message) async {print(message);}
@overrideFuture<bool> reportEvent(int eventId, String eventName, AppInfo appInfo,Map<Object?, Object?> params) async {print("reportEvent:$eventName appinfo:$appInfo params:$params");// TODO: implement reportEventreturn Future.value(false);}
Future<void> startMiniAppWithId(String appId, MiniStartOptions? options)
Future<void> startMiniAppWithLink(String link, MiniStartOptions? options)
Future<ScanResult?> scan()
Future<List<AppInfo>?> getRecentList()
Future<List<AppInfo>?> searchMiniApp(String keyword,{int pageIndex = 0, int pageSize = 0})
Future<void> stopMiniApp(String appId)
Future<void> stopAllMiniApp()
Future<void> deleteMiniAppCache(String appId,{int appVerType = 0, String? ver
Future<AppInfo?> currentMiniApp()
Future<void> preDownloadMiniApp(List<String> appIdList,{bool isDownload = false})
void registerOpenApiHandler(OpenApiHandler handler)
void registerPlatformEventHandler(TcmppPlatformEventHandler handler)
void registerMiniAppApi(String apiName, TcmppMiniAppApiHandler apiHandler)
void setAccount(AccountInfo? info)
Future<void> setLocale(String language,{String? region, String? variant})
Future<void> setTheme(MiniTheme theme)
class MiniStartOptions {/// entry path of mini programString? entryPath;/// is always update mini program when startbool? isForceUpdate;/// string param passed to mini program when startString? params;}
class ScanResult {/// result string of qrcode or barcode containsString? result;/// the type of codeString? scanType;/// charset of result stringString? charset;}
class AppInfo {/// MiniProgram idString appId;/// MiniProgram package type (release, dev, etc.). See [AppVerType]int appVerType;/// MiniProgram versionString version;/// MiniProgram nameString? name;/// MiniProgram icon urlString? iconUrl;/// MiniProgram descriptionString? appIntro;/// Developer of MiniProgramString? appDeveloper;/// MiniProgram release timeint time;}
/// Consts for MiniProgram package type. see[AppInfo]class AppVerType {static const int online = 0;static const int develop = 1;static const int preview = 2;static const int experience = 3;}
class AccountInfo {/// Unique id of current accountString? uid;/// Url of avatar imageString? avatarUrl;/// Name of current accountString? accountName;}
abstract class OpenApiHandler {/// Called when mini-program invoke wx.requestPayment, requesting third-party payment action///Future<Map<String, dynamic>> requestPayment(AppInfo appInfo, Map<Object?, Object?> params);/// Called when mini-program invoke wx.getUserProfile, requesting host app's user information///Future<Map<String, dynamic>> getUserProfile(AppInfo appInfo, Map<Object?, Object?> params);/// Called when mini-program invoke wx.login, requesting host app's login certificate///Future<Map<String, dynamic>> login(AppInfo appInfo, Map<Object?, Object?> params);/// Called when mini-program invoke wx.checkSession, requesting host app's login state/// check if login expired///Future<Map<String, dynamic>> checkSession(AppInfo appInfo, Map<Object?, Object?> params);/// Called when mini-program invoke wx.getUserInfo, deprecated by wx.getUserProfile/// compatibility for earlier mini-program api///Future<Map<String, dynamic>> getUserInfo(AppInfo appInfo, Map<Object?, Object?> params);/// Called when mini-program invoke wx.getPhoneNumber, get current user's phone number///Future<Map<String, dynamic>> getPhoneNumber(AppInfo appInfo, Map<Object?, Object?> params);}
abstract class TcmppPlatformEventHandler {Future<String> getAppName() async {return "";}Future<String> getAppVersion() async {return "";}Future<void> log(String message) async {}Future<List<CustomMenu>> getCustomMenus() async {return [];}Future<void> customMenuClick(String menuId, ShareData? shareMenu) async {}Future<void> onMiniProgramStateChange(String appId, MiniProgramState state) async {}Future<bool> reportEvent(int eventId, String eventName, AppInfo appInfo,Map<Object?, Object?> params) async {return false;}}
Was this page helpful?