# Flutter Common Issues
# 1. Is the menu in the more button at the top-right corner of the Mini-Program customizable? If yes, how to implement it?
Answer: Yes. However, the implementation differs between iOS and Android and requires separate handling.
iOS
First, create a channel for Flutter to communicate with the native project.
const toAppMessageChannel = MethodChannel("com.message.flutter_to_app");
Then, create an implementation class that inherits from AppletHandler.
class MyAppletHandler extends AppletHandler {
...
bool customCapsuleMoreButtonClick(String appId) {
// Return true to indicate customizing the more view; return false to use the default more view.
// Note: This delegate method only takes effect on iOS. For Android, refer to the common issues list.
// Send an event to the native iOS code via the channel here.
toAppMessageChannel.invokeMethod("showCustomMoreView", {"appId": appId});
return true;
}
...
}
Then, register the delegate implementation object.
Mop.instance.registerAppletHandler(MyAppletHandler());
Finally, listen for the channel event in the iOS native project and handle the logic for displaying the custom more view.
_channel = [FlutterMethodChannel methodChannelWithName:@"com.message.flutter_to_app" binaryMessenger:messenger];
[_channel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
NSLog(@"Received Flutter message: %@", call.method);
if ([call.method isEqualToString:@"showCustomMoreView"]) {
NSString *appId = call.arguments[@"appId"];
// Display the custom more view
UIViewController *viewController = [[UIApplication sharedApplication] fat_topViewController];
UIAlertController *alertViewController = [UIAlertController alertControllerWithTitle:@"More View" message:appId preferredStyle:UIAlertControllerStyleActionSheet];
[alertViewController addAction:[UIAlertAction actionWithTitle:@"Forward" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alertViewController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];
[viewController presentViewController:alertViewController animated:YES completion:nil];
}
}];
Android
- First, create a new Application in the Android project.
- Then, configure the Application's name in
AndroidManifest.xml. - Next, register the delegate implementation object in the Application's
onCreatemethod. - Finally, override the method for the more button click event.
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
initProcessHandler();
}
private void initProcessHandler() {
if (!FinAppClient.INSTANCE.isFinAppProcess(this)) {
return;
}
FinAppProcessClient.INSTANCE.getAppletProcessApiManager().setAppletProcessHandler(new IAppletProcessHandler(){
@Override
public boolean onNavigationBarMoreButtonClicked(@NonNull Context context, @NonNull String appId) {
// Display the custom more view here
new AlertDialog.Builder(context)
.setTitle("More View")
.setMessage(appId)
.setPositiveButton("Menu", null)
.setNegativeButton("Cancel", null)
.show();
// Return true to handle the more view yourself; return false to use the default more view
return true;
}
});
}
}
# 2. How to support internationalization for common UI?
If only switching between Chinese and English is needed, the SDK supports this by default. Simply modify the configuration as follows (effective for both iOS and Android).
When initializing the SDK, set the
languageparameter in the Config object toLanguageType.EnglishorLanguageType.Chinese(Simplified Chinese).
// Multi-server configuration
FinStoreConfig storeConfigA = FinStoreConfig(
"SDK key",
"SDK secret",
"Server address",
cryptType: "SM",
);
List<FinStoreConfig> storeConfigs = [storeConfigA];
Config config = Config(storeConfigs);
config.language = LanguageType.English;
- If other languages need to be set, the configuration for Android and iOS will differ. Additionally, you need to provide your own internationalization text resources.
Android as follows:
FinStoreConfig storeConfigA = FinStoreConfig(
"SDK key",
"SDK secret",
"Server address",
cryptType: "SM",
);
List<FinStoreConfig> storeConfigs = [storeConfigA];
Config config = Config(storeConfigs);
/// For language list strings, refer to: https://uutool.cn/info-i18n/ or the Java class 【java.util.Locale】 for details.
config.localeLanguage = "zh_TW"; // Traditional Chinese
Notes:
- The priority of this configuration is higher than the above
config.languageand is only effective on the Android platform. - The SDK only has built-in internationalization resources for Simplified Chinese and English. For other languages, you need to add them yourself. Refer to the documentation: Internationalizing the Android SDK (opens new window)
- The project contains corresponding Android project files; refer to the Android SDK's internationalization configuration. New language configurations should also be placed in the relevant directories of the corresponding Android project.
iOS as follows:
The keys for custom internationalization languages need to be obtained from FinApplet.framework, located at: FinApplet.framework/FinApplet.bundle/zh-Hans.lproj/Localizable.strings
Taking Japanese as an example, create an internationalization file directory jp.lproj in the iOS development project, create a Localizable.strings file within it, copy the keys from our FinApplet.framework into this file, and translate them.
Configuration code:
FinStoreConfig storeConfigA = FinStoreConfig(
"SDK key",
"SDK secret",
"Server address",
cryptType: "SM",
);
List<FinStoreConfig> storeConfigs = [storeConfigA];
Config config = Config(storeConfigs);
if (Platform.isIOS) {
// If the jp.lproj directory is placed directly in the project directory (i.e., under the mainBundle), initialize as follows:
config.customLanguagePath = "jp.lproj";
// Alternatively, if the jp.lproj files are stored within a custom bundle, include the relative path:
// config.customLanguagePath = "XXX.bundle/jp.lproj";
}
# 3. How to customize the Mini-Program's loading page?
First, you need to create a custom loading view in both the iOS and Android projects, which should inherit or implement FATBaseLoadingView and IFinAppletLoadingPage respectively.
Refer to Setting the Loading Page UI for guidance.
Then, configure the class of your custom loading view during Flutter SDK initialization.
Note
The configuration items for setting the custom loading view are different for the two platforms!!
// iOS
...
Config config = Config(storeConfigs);
config.baseLoadingViewClass = "LoadingView";
...
// Android
...
UIConfig uiconfig = UIConfig();
uiconfig.loadingLayoutCls = "com.finogeeks.mop_example.CustomLoadingPage";
# 4. How to integrate Extension SDKs in a Flutter project?
The Flutter SDK for FinClip is Mop. The Mop SDK depends on the core SDKs and Base Library Extension SDKs for Android and iOS by default.
// iOS SDKs depended on by Mop:
FinApplet
FinAppletExt
// Android SDKs depended on by Mop:
finapplet
plugins
When your Mini-Program in the Flutter project requires APIs or Components from other Extension SDKs, you can add dependencies for those Extension SDKs in the Android and iOS projects. iOS Add the required Extension SDKs in the Podfile under the ios folder in the root directory. Example:
// Map component and location API implemented with AMap
pod 'FinAppletGDMap', '2.42.8-alpha20231127v04'
// Bluetooth-related APIs
pod 'FinAppletBLE', '2.42.8-alpha20231127v04'
// Contact API
pod 'FinAppletContact', '2.42.8-alpha20231127v04'
// Clipboard API
pod 'FinAppletClipBoard', '2.42.8-alpha20231127v04'
// Live component
pod 'FinAppletLive', '2.42.8-alpha20231127v04'
// Share Extension SDK
pod 'FinAppletShare', '2.42.8-alpha20231127v04'
// WeChat Extension SDK
pod 'FinAppletWXExt', '2.42.8-alpha20231127v04'
// Calendar API
pod 'FinAppletCalendar', '2.42.8-alpha20231127v04'
For more detailed descriptions of the Mini-Program APIs included in each iOS Extension SDK and the Extension SDKs themselves, see iOS Extension SDKs
Android Add the Extension SDKs in the build.gradle file under android/app in the root directory. Example:
implementation "com.finogeeks.mop:live:${sdk_version}"
// Map component and location API
implementation "com.finogeeks.mop:map:${sdk_version}"
// Bluetooth API
implementation "com.finogeeks.mop:bluetooth:${sdk_version}"
// Contact API
implementation "com.finogeeks.mop:contact:${sdk_version}"
// Clipboard API
implementation "com.finogeeks.mop:clipboard:${sdk_version}"
// Video casting Extension SDK
implementation "com.finogeeks.mop:cast:${sdk_version}"
// Share Extension SDK
implementation "com.finogeeks.mop:share:${sdk_version}"
// Xlog logging Extension SDK
implementation "com.finogeeks.mop:xlog:${sdk_version}"
// Calendar API
implementation "com.finogeeks.mop:calendar:${sdk_version}"
For more detailed descriptions of the Mini-Program APIs included in each Android Extension SDK and the Extension SDKs themselves, see Android Extension SDKs