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.
 
 
 
 
 
 

88 lines
3.8 KiB

#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import "WXApi.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
// 消息内容获取
__block NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(@"notification dic: %@", remoteNotification);
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"]) {
if (remoteNotification != NULL) {
result(remoteNotification[@"custom"]);
remoteNotification = nil;
}
result(@"");
}
if ([method isEqual:@"toAppStore"]) {
NSString *appURL = @"https://itunes.apple.com/cn/app/1575124838?action=write-review";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
result(@"");
}
//result(FlutterMethodNotImplemented);
}];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
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);
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"]) {
if (customParam != NULL) {
result(customParam);
customParam = @"";
}
result(@"");
}
if ([method isEqual:@"toAppStore"]) {
NSString *appURL = @"https://itunes.apple.com/cn/app/1575124838?action=write-review";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
result(@"");
}
//result(FlutterMethodNotImplemented);
}];
// 通过通用链接唤起 App
// [DCUniMPSDKEngine application:application continueUserActivity:userActivity];
return YES;
}
//- (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]];
//}
@end