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.

89 lines
3.8 KiB

4 years ago
#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
4 years ago
#import "WXApi.h"
4 years ago
3 years ago
4 years ago
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
3 years ago
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
4 years ago
4 years ago
3 years ago
// 消息内容获取
3 years ago
__block NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
3 years ago
NSLog(@"notification dic: %@", remoteNotification);
4 years ago
3 years ago
FlutterMethodChannel* bridgeAppChannel = [FlutterMethodChannel methodChannelWithName:@"bridge" binaryMessenger:(NSObject<FlutterBinaryMessenger> *)controller];
[bridgeAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
NSString * method = call.method;
if ([method isEqual:@"action"]) {
3 years ago
if (remoteNotification != NULL) {
result(remoteNotification[@"custom"]);
3 years ago
remoteNotification = nil;
3 years ago
}
result(@"");
3 years ago
}
3 years ago
if ([method isEqual:@"toAppStore"]) {
3 years ago
NSString *appURL = @"https://itunes.apple.com/cn/app/1575124838?action=write-review";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
result(@"");
}
3 years ago
//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 {
3 years ago
NSLog(@"userActivity%@", userActivity.webpageURL);
NSArray *params = [userActivity.webpageURL.query componentsSeparatedByString:@"&"];
__block NSString *customParam = @"";
for (NSString *string in params) {
NSLog(@"userActivity%@", string);
NSArray *array =[string componentsSeparatedByString:@"="];
if ([array[0] isEqual:@"id"]) {
customParam = [NSString stringWithFormat:@"{\"typed\":1,\"info\":\"%@\"}", array[1]];
}
}
NSLog(@"userActivity%@", customParam);
3 years ago
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
FlutterMethodChannel* bridgeAppChannel = [FlutterMethodChannel methodChannelWithName:@"bridge" binaryMessenger:(NSObject<FlutterBinaryMessenger> *)controller];
[bridgeAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
NSString * method = call.method;
if ([method isEqual:@"action"]) {
3 years ago
if (customParam != NULL) {
result(customParam);
customParam = @"";
3 years ago
}
result(@"");
}
3 years ago
if ([method isEqual:@"toAppStore"]) {
3 years ago
NSString *appURL = @"https://itunes.apple.com/cn/app/1575124838?action=write-review";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
result(@"");
}
3 years ago
//result(FlutterMethodNotImplemented);
}];
4 years ago
// 通过通用链接唤起 App
3 years ago
// [DCUniMPSDKEngine application:application continueUserActivity:userActivity];
4 years ago
return YES;
}
4 years ago
//- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler responseHandler]];
//}
//
//- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options{
// return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler responseHandler]];
//}
4 years ago
@end