@interface MIniAppDemoSDKDelegateImpl : NSObject <TMFMiniAppSDKDelegate>@end
[TMFMiniAppSDKManager sharedInstance].miniAppSdkDelegate = [MIniAppDemoSDKDelegateImpl sharedInstance];
/*** @brief SDK Host Application Name* Primarily used for textual prompts.*/- (NSString *)appName;/*** @brief SDK Host Platform Version* @return Returns a lowercase string, for example, 1.0.0.*/- (NSString *)getAppVersion;/*** @brief SDK Host Platform QUA*/- (NSString *)getAppQUA;/*** @brief Network Status of the SDK Host Platform*/- (TMANetWorkStatus)getAppNetworkStatus;/*** @brief Device Information of the SDK Host Platform*/- (NSString *)getAppIPhoneModel;/*** @brief Current Language Set by the Host*/- (NSString *)getCurrentLocalLanguage;/*** @brief Clipboard Frequency Control*/- (NSNumber *)getClipboardInterval;/// Customized User Agent/// @param defaultUserAgent: Default user agent in use- (NSString *)customUserAgent:(NSString *)defaultUserAgent;
/*** @brief User nickname of the SDK host platform. The default return is "TMF Mini Program".*/- (NSString *)getAppNickName;/*** @brief User avatar of the SDK host platform, The default return is a demo image.*/- (UIImage *)getAppAvatar;/*** @brief Retrieve the current user account identifier of the SDK host platform, typically filled with uin or openid.** Note: Returning nil may cause some caches within the SDK to become invalid. If not logged in, you can fill in a device id to avoid cache invalidation.*/- (NSString *_Nonnull)getAppUID;
/// Initiate Payment/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)requestPayment:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;/// login/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)login:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;/// checkSession/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)checkSession:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;/// getAccountInfoSync/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)getAccountInfoSync:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;/// getUserProfile/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)getUserProfile:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;/// getUserInfo/// @param app: Mini Program/Mini Game Instance/// @param params: Parameters/// @param completionHandler: Callback Result- (void)getUserInfo:(TMFMiniAppInfo *)app params:(NSDictionary *)params completionHandler:(MACommonCallback)completionHandler;
/// Display Loading/// @param infos Loading Information- (void)showLoading:(TMALoadingInfo * _Nullable)infos;/// Hide Loading- (void)hideLoading;/// Display Toast/// @param infos Toast Information- (void)showToast:(TMAToastInfo *)infos;/// Hide Toast- (void)hideToast;/// Display ActionSheet/// @param title: Title/// @param cancelButtonTitle: Cancel button title/// @param cancelAction: Action triggered by clicking the "Cancel" button/// @param otherButtonTitleAndActions: Other buttons and corresponding actions/// @param dismissBlock: Actions to be executed after the ActionSheet is dismissed (must be called to ensure correct functionality.)/// @param presentingViewController: ViewController presenting the ActionSheet- (void)showActionSheetWithTitle:(nullable NSString *)titlecancelButtonTitle:(nullable NSString *)cancelButtonTitlecancelAction:(nullable dispatch_block_t)cancelActionotherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActionsdismissBlock:(nullable dispatch_block_t)dismissBlockpresentingViewController:(UIViewController *)presentingViewController;/// Share Panel/// If this method is not implemented, "showActionSheetWithTitle:cancelButtonTitle:cancelAction:otherButtonTitleAndActions:dismissBlock:presentingViewController:" will be called./// @param title: Title/// @param cancelAction: Cancel operation/// @param otherButtonTitleAndActions: Other buttons and corresponding actions/// @param dismissBlock: Actions to be executed after the panel is dismissed (must be called to ensure correct functionality.)/// @param parentVC: ViewController initiating the panel- (void)showShareViewWithTitle:(nullable NSString *)titlecancelAction:(nullable dispatch_block_t)cancelActionotherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActionsdismissBlock:(nullable dispatch_block_t)dismissBlockparentVC:(UIViewController *)parentVC;/// Panel Invoked by Clicking the Capsule Button/// If this method is not implemented, "showActionSheetWithTitle:cancelButtonTitle:cancelAction:otherButtonTitleAndActions:dismissBlock:presentingViewController:" will be called./// @param app: Mini Program information/// @param cancelButtonTitle: Cancel title/// @param cancelAction: Cancel operation/// @param otherButtonTitleAndActions: Other buttons and corresponding actions/// @param dismissBlock: Actions to be executed after the panel is dismissed (must be called to ensure correct functionality.)- (void)showMoreButtonActionSheetWithApp:(TMFMiniAppInfo *)appcancelButtonTitle:(nullable NSString *)cancelButtonTitlecancelAction:(nullable dispatch_block_t)cancelActionotherButtonTitleAndActions:(nullable NSArray *)otherButtonTitleAndActionsdismissBlock:(nullable dispatch_block_t)dismissBlock;/// Dismiss All Actionsheets Invoked by Mini Programs/Mini Games- (void)clearAllActionSheet;/// Invoke Alert Dialog Box/// @param title: Title/// @param message: Information/// @param actionTitleAndblocks: Button titles and response actions./// @param presentingViewController: View Controller invoking the Alert dialog box- (void)showAlertWithTitle:(nullable NSString *)titlewithMessage:(nullable NSString *)messageactionBlocks:(nullable NSArray<AlertActionInfo *> *)actionTitleAndblockspresentingViewController:(UIViewController *)presentingViewController;/*** @brief Display Popup Window** @param title Title* @param message Message* @param actionTitleAndblocks Button Titles and Corresponding actions* @param isDismissWhenBackground: Determines if the popup window disappears when the Mini Program runs at the backend.* @param dismissOnClickBlank: Determines if the popup window disappears when the blank background area is clicked.* @param presentingViewController ViewController Initiating the Alert Dialog*/- (void)showPopupWithTitle:(NSString *)titlemessage:(NSString *)messageactionBlocks:(NSArray<AlertActionInfo *> *)actionTitleAndblocksisDismissWhenBackground:(BOOL)isDismissWhenBackgrounddismissOnClickBlank:(BOOL)dismissOnClickBlankpresentingViewController:(UIViewController *)presentingViewController;/// The Host App can customize the sharing channels and determine the display sequence. It is currently used in the ActionSheet invoked by clicking the 'More' button, and the button component (open-type="share")./// 1. Default channels: QQ Friends, QQ Space, WeChat, Moments (for specific types, refer to MAUIDelegateShareViewType), determined by the developer, with the Host App only able to change the display sequence./// 2. Custom Channels: Customized by the Host App (type filled as MAUIDelegateShareViewTypeCustomizedShare)/// The display sequence of the above two channels supports intermixing.- (NSArray<TMASheetItemInfo *> *)customizedConfigForShare;/// Whether the Host App is in the Dark Mode.- (BOOL)isDarkMode;/// The Host App can return a custom WKWebView, currently used for/// 1. Web-view Component: It is necessary to address the issue of the body being lost in post requests sent via xhr within the web-view component.- (WKWebView *)webViewWithConfiguration:(WKWebViewConfiguration *)configuration;
/// Invoking the client's scanning module, scancode, by scanning./// @param scanParams: Dictionary of scanning parameters./// @param navigationController: The page from which the vc is invoked./// @param completionHandler: Callback Result- (void)scanCode:(NSDictionary *)scanPramsnavigationController:(UINavigationController *)navigationControllercompletionHandler:(MACommonCallback)completionHandler;/// Selecting media from the image picker./// @param model: Configuration/// @param parentVC vc/// @param completionBlock: Data to be returned after selection, accepting TMAPickerImageModel or TMAPickerVideoModel based on the selected type.- (void)selectMediaFromPickerWithModel:(TMAMediaChooseConfigModel *)modelparentVC:(UIViewController *)parentVCcompletionBlock:(void(^)(NSArray * _Nullable medias, NSError * _Nullable error))completionBlock;/// Capturing media/// @param model: Configuration/// @param parentVC vc/// @param completionBlock: Data to be returned after selection, accepting TMACameraImageModel or TMACameraVideoModel based on the selected type.- (void)selectMediaFromCameraWithModel:(TMAMediaChooseConfigModel *)modelparentVC:(UIViewController *)parentVCcompletionBlock:(void(^)(id _Nullable media, NSError * _Nullable error))completionBlock;/// Getting image data from PHAsset./// @param phAsset: Media object/// @param needCompress: Whether compression is required.- (NSData *)imageDataFromPhAsset:(PHAsset *)phAsset needCompress:(BOOL)needCompress;/// Image preview/// @param navigationController: Navigation bar invoking the image preview./// @param currentAbsoluteUrl: Current page address./// @param absUrlsInPreviewArray: Images to be previewed.- (void)navigationController:(UINavigationController *)navigationControllerpresentImageWithCurrentUrl:(NSString *)currentAbsoluteUrlimageUrlArray:(NSArray *)absUrlsInPreviewArray;
// Handling errors that occur during the startup process.- (void)handleStartUpError:(NSError *_Nonnull)errorapp:(NSString *_Nullable)appparentVC:(UIViewController *_Nonnull)parentVC;// Mini Program successfully launched.- (void)handleStartUpSuccessWithApp:(TMFMiniAppInfo *_Nonnull)app;
/// Print Log/// @param level: Log level (refer to PLTLogLevel for details)./// @param msg Log information.- (void)log:(MALogLevel)level msg:(NSString *)msg;
/// Handle the current app's configuration items for the Mini Program engine./// @param key: Configuration item key and supported features (refer to the definitions in TMAConfigDefine.h)./// An example of a custom "Close" icon for the capsule button- (NSString*)stringWithConfigKey:(NSString *)key {if([key isEqualToString:TMA_SK_MINIAPP_CloseButton]) {return [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"white_close-circle.png"];} else if([key isEqualToString:TMA_SK_MINIAPP_CloseButtonDark]) {return [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"dark_close-circle.png"];}return nil;}
- (void)applet:(TMFMiniAppInfo *)appletInfo screenCaptureStatusChanged:(BOOL)isCapture atPagePath:(NSString *)pagePath;- (void)appletDidTakeScreenshot:(TMFMiniAppInfo *)appletInfo atPagePath:(NSString *)pagePath;- (nullable UIView *)appletCustomizeWatermarkView:(TMFMiniAppInfo *)appletInfo;
Was this page helpful?