You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
3.9 KiB

4 years ago
#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import "DCUniMP.h"
4 years ago
#import "UniappPlugin.h"
4 years ago
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
4 years ago
// 配置参数
4 years ago
NSMutableDictionary *options = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
// 设置 debug YES 会在控制台输出 js log,默认不输出 log,注:需要引入 liblibLog.a
[options setObject:[NSNumber numberWithBool:YES] forKey:@"debug"];
[DCUniMPSDKEngine initSDKEnvironmentWithLaunchOptions:options ];
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
FlutterMethodChannel* uniAppChannel = [FlutterMethodChannel methodChannelWithName:@"min" binaryMessenger:controller];
UniappPlugin * plugin = [[UniappPlugin alloc] init];
[DCUniMPSDKEngine setDelegate:plugin];
[uniAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
NSString * method = call.method;
if ([method isEqual:@"initialize"] || [method isEqual:@"isInitialize"]) {
result([NSNumber numberWithBool:YES]);
}
//是否已经解压过了
if ([method isEqual:@"isExistsApp"]) {
NSString * appid = [call.arguments valueForKey:@"appid"];
[DCUniMPSDKEngine isExistsApp:appid] ? result([NSNumber numberWithBool:YES]): result([NSNumber numberWithBool:NO]);
}
if ([method isEqual:@"closeCurrentApp"]) {
[DCUniMPSDKEngine closeUniMP];
}
if ([method isEqual:@"getAppBasePath"]) {
4 years ago
NSString * appid = [call.arguments valueForKey:@"appid"];
result([DCUniMPSDKEngine getAppRunPathWithAppid:appid]);
4 years ago
}
if ([method isEqual:@"runingAppid"]) {
result([DCUniMPSDKEngine getActiveUniMPAppid]);
}
if ([method isEqual:@"currentPageUrl"]) {
result([DCUniMPSDKEngine getCurrentPageUrl]);
}
if ([method isEqual:@"startMin"]) {
NSLog(@"call.arguments:%@",call.arguments);
NSString * appid = [call.arguments valueForKey:@"appid"];
NSDictionary* dict = [call.arguments objectForKey:@"json"];
[plugin openUniApp:appid dict:dict];
result(@"");
}
if ([method isEqual:@"getAppVersionInfo"]) {
NSString * appid = [call.arguments valueForKey:@"appid"];
result([[DCUniMPSDKEngine getUniMPVersionInfoWithAppid:appid] valueForKey:@"name"]);
}
if ([method isEqual:@"reloadWgt"]) {
NSString * appid = [call.arguments valueForKey:@"appid"];
NSString * wgtPath = [call.arguments valueForKey:@"wgtPath"];
BOOL r = [DCUniMPSDKEngine releaseAppResourceToRunPathWithAppid:appid resourceFilePath:wgtPath];
r ? result([NSNumber numberWithBool:YES]) : result([NSNumber numberWithBool:NO]);
}
//这是原来的下载
if ([call.method isEqual:@"openUniApp"]) {
result(@"这是原来的下载。");
}
//result(FlutterMethodNotImplemented);
}];
4 years ago
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
4 years ago
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
// 通过通用链接唤起 App
[DCUniMPSDKEngine application:application continueUserActivity:userActivity];
return YES;
}
4 years ago
@end