提交 45b4bbfb authored 作者: JarvanMo's avatar JarvanMo

ios AppDelegate 调整

上级 6e751a2f
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
// return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; // return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
//} //}
// //
//
//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { //- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
// [super application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
// return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; // return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
//} }
//// NOTE: 9.0以后使用新API接口 //// NOTE: 9.0以后使用新API接口
//- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options //- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
//{ //{
// // [super application:app openURL:url options:options];
// return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; // return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
//} //}
......
import UIKit
import Flutter
import fluwx
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return WXApi.handleOpen(url, delegate: FluwxResponseHandler.defaultManager())
}
// NOTE: 9.0以后使用新API接口
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return WXApi.handleOpen(url, delegate: FluwxResponseHandler.defaultManager())
}
}
//
// Generated file. Do not edit.
//
#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h
#import <Flutter/Flutter.h>
@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end
#endif /* GeneratedPluginRegistrant_h */
//
// Generated file. Do not edit.
//
#import "GeneratedPluginRegistrant.h"
#import <fluwx/FluwxPlugin.h>
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[FluwxPlugin registerWithRegistrar:[registry registrarForPlugin:@"FluwxPlugin"]];
}
@end
#import "GeneratedPluginRegistrant.h"
...@@ -26,8 +26,7 @@ FluwxLaunchMiniProgramHandler *_fluwxLaunchMiniProgramHandler; ...@@ -26,8 +26,7 @@ FluwxLaunchMiniProgramHandler *_fluwxLaunchMiniProgramHandler;
FluwxSubscribeMsgHandler *_fluwxSubscribeMsgHandler; FluwxSubscribeMsgHandler *_fluwxSubscribeMsgHandler;
FluwxAutoDeductHandler *_fluwxAutoDeductHandler; FluwxAutoDeductHandler *_fluwxAutoDeductHandler;
- (void)dealloc - (void)dealloc {
{
// [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[NSNotificationCenter defaultCenter] removeObserver:self];
} }
...@@ -51,20 +50,18 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler; ...@@ -51,20 +50,18 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler;
// object:nil]; // object:nil];
if (self) { if (self) {
_fluwxShareHandler = [[FluwxShareHandler alloc] initWithRegistrar:registrar]; _fluwxShareHandler = [[FluwxShareHandler alloc] initWithRegistrar:registrar];
_fluwxAuthHandler = [[FluwxAuthHandler alloc] initWithRegistrar:registrar methodChannel:flutterMethodChannel] ; _fluwxAuthHandler = [[FluwxAuthHandler alloc] initWithRegistrar:registrar methodChannel:flutterMethodChannel];
_fluwxWXApiHandler = [[FluwxWXApiHandler alloc] init]; _fluwxWXApiHandler = [[FluwxWXApiHandler alloc] init];
_fluwxPaymentHandler = [[FluwxPaymentHandler alloc] initWithRegistrar:registrar]; _fluwxPaymentHandler = [[FluwxPaymentHandler alloc] initWithRegistrar:registrar];
_fluwxLaunchMiniProgramHandler = [[FluwxLaunchMiniProgramHandler alloc] initWithRegistrar:registrar]; _fluwxLaunchMiniProgramHandler = [[FluwxLaunchMiniProgramHandler alloc] initWithRegistrar:registrar];
_fluwxSubscribeMsgHandler = [[FluwxSubscribeMsgHandler alloc] initWithRegistrar:registrar]; _fluwxSubscribeMsgHandler = [[FluwxSubscribeMsgHandler alloc] initWithRegistrar:registrar];
_fluwxAutoDeductHandler =[[FluwxAutoDeductHandler alloc] initWithRegistrar:registrar]; _fluwxAutoDeductHandler = [[FluwxAutoDeductHandler alloc] initWithRegistrar:registrar];
} }
return self; return self;
} }
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
...@@ -73,48 +70,48 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler; ...@@ -73,48 +70,48 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler;
return; return;
} }
if([@"isWeChatInstalled" isEqualToString :call.method]){ if ([@"isWeChatInstalled" isEqualToString:call.method]) {
[_fluwxWXApiHandler checkWeChatInstallation:call result:result]; [_fluwxWXApiHandler checkWeChatInstallation:call result:result];
return; return;
} }
if([@"sendAuth" isEqualToString :call.method]){ if ([@"sendAuth" isEqualToString:call.method]) {
[_fluwxAuthHandler handleAuth:call result:result]; [_fluwxAuthHandler handleAuth:call result:result];
return; return;
} }
if([@"payWithFluwx" isEqualToString :call.method]){ if ([@"payWithFluwx" isEqualToString:call.method]) {
[_fluwxPaymentHandler handlePayment:call result:result]; [_fluwxPaymentHandler handlePayment:call result:result];
return; return;
} }
if([@"launchMiniProgram" isEqualToString :call.method]){ if ([@"launchMiniProgram" isEqualToString:call.method]) {
[_fluwxLaunchMiniProgramHandler handleLaunchMiniProgram:call result:result]; [_fluwxLaunchMiniProgramHandler handleLaunchMiniProgram:call result:result];
return; return;
} }
if([@"subscribeMsg" isEqualToString: call.method]){ if ([@"subscribeMsg" isEqualToString:call.method]) {
[_fluwxSubscribeMsgHandler handleSubscribeWithCall:call result:result]; [_fluwxSubscribeMsgHandler handleSubscribeWithCall:call result:result];
return; return;
} }
if([@"authByQRCode" isEqualToString:call.method]){ if ([@"authByQRCode" isEqualToString:call.method]) {
[_fluwxAuthHandler authByQRCode:call result:result]; [_fluwxAuthHandler authByQRCode:call result:result];
return; return;
} }
if([@"stopAuthByQRCode" isEqualToString:call.method]){ if ([@"stopAuthByQRCode" isEqualToString:call.method]) {
[_fluwxAuthHandler stopAuthByQRCode:call result:result]; [_fluwxAuthHandler stopAuthByQRCode:call result:result];
return; return;
} }
if([@"autoDeduct" isEqualToString:call.method]){ if ([@"autoDeduct" isEqualToString:call.method]) {
[_fluwxAutoDeductHandler handleAutoDeductWithCall:call result:result]; [_fluwxAutoDeductHandler handleAutoDeductWithCall:call result:result];
return; return;
} }
if([@"openWXApp" isEqualToString:call.method]){ if ([@"openWXApp" isEqualToString:call.method]) {
result(@([WXApi openWXApp])); result(@([WXApi openWXApp]));
return; return;
} }
...@@ -132,22 +129,20 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler; ...@@ -132,22 +129,20 @@ FluwxAutoDeductHandler *_fluwxAutoDeductHandler;
[WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
return NO; return NO;
} }
// NOTE: 9.0以后使用新API接口
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
[WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; // NOTE: 9.0以后使用新API接口
return NO; - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
} }
-(BOOL)handleOpenURL:(NSNotification *)aNotification { - (BOOL)handleOpenURL:(NSNotification *)aNotification {
if(handleOpenURLByFluwx){ if (handleOpenURLByFluwx) {
NSString * aURLString = [aNotification userInfo][@"url"]; NSString *aURLString = [aNotification userInfo][@"url"];
NSURL * aURL = [NSURL URLWithString:aURLString]; NSURL *aURL = [NSURL URLWithString:aURLString];
return [WXApi handleOpenURL:aURL delegate:[FluwxResponseHandler defaultManager]]; return [WXApi handleOpenURL:aURL delegate:[FluwxResponseHandler defaultManager]];
} else{ } else {
return NO; return NO;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论