Skip to content

Commit

Permalink
support enable/disable scene_delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed May 17, 2023
1 parent 870cbe1 commit 6c02b1e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluwx: d725e175af372180498ce6daad7be464f48c78b5
fluwx: 3c7b6df42f83d444d4538f3eaeae079f12d30c37
integration_test: 13825b8a9334a850581300559b8839134b124670
WechatOpenSDK-XCFramework: acdeeda129efbef9532bca8a10c24e1b4b8c7d69

Expand Down
9 changes: 5 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ flutter:
# see https://flutter.dev/custom-fonts/#from-packages

fluwx:
# app_id: 123456
# only debug in debug mode
# app_id: 123456
# only debug in debug mode
debug_logging: true
android:
# interrupt_wx_request: true # default is true
# flutter_activity: MainActivity #Default to launch app's launcher
# interrupt_wx_request: true # default is true
# flutter_activity: MainActivity #Default to launch app's launcher
ios:
universal_link: https://testdomain.com
scene_delegate: true #default false
# payment is enabled by default
# no_pay: true
5 changes: 5 additions & 0 deletions ios/Classes/FluwxPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,17 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction
return [WXApi handleOpenURL:url delegate:self];
}

#ifndef SCENE_DELEGATE
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nonnull))restorationHandler{
return [WXApi handleOpenUniversalLink:userActivity delegate:self];
}
#endif

#ifdef SCENE_DELEGATE
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity API_AVAILABLE(ios(13.0)){
[WXApi handleOpenUniversalLink:userActivity delegate:self];
}
#endif

- (void)handleOpenUrlCall:(FlutterMethodCall *)call
result:(FlutterResult)result {
Expand Down
31 changes: 18 additions & 13 deletions ios/fluwx.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ calling_dir = File.dirname(__FILE__)
project_dir = calling_dir.slice(0..(calling_dir.index('/.symlinks')))
flutter_project_dir = calling_dir.slice(0..(calling_dir.index('/ios/.symlinks')))
cfg = YAML.load_file(File.join(flutter_project_dir, 'pubspec.yaml'))
debug_logging = false
logging_status = "WECHAT_LOGGING=0"

if cfg['fluwx'] && cfg['fluwx']['debug_logging'] == true
debug_logging = true
logging_status = 'WECHAT_LOGGING=1'
else
logging_status = 'WECHAT_LOGGING=0'
end

scene_delegate = ''
if cfg['fluwx'] && cfg['fluwx']['ios'] && cfg['fluwx']['ios']['scene_delegate'] == true
scene_delegate = 'SCENE_DELEGATE=1'
else
scene_delegate = ''
end


if cfg['fluwx'] && cfg['fluwx']['ios'] && cfg['fluwx']['ios']['no_pay'] == true
fluwx_subspec = 'no_pay'
else
Expand All @@ -34,6 +45,7 @@ if cfg['fluwx'] && cfg['fluwx']['app_id']
app_id = cfg['fluwx']['app_id']
end


if cfg['fluwx'] && (cfg['fluwx']['ios'] && cfg['fluwx']['ios']['universal_link'])
universal_link = cfg['fluwx']['ios']['universal_link']
if app_id.nil?
Expand Down Expand Up @@ -70,24 +82,17 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
s.subspec 'pay' do |sp|
sp.dependency 'WechatOpenSDK-XCFramework','~> 2.0.2'

if debug_logging
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = '$(inherited) WECHAT_LOGGING=1'
else
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = '$(inherited) WECHAT_LOGGING=0'
end
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = "$(inherited) #{logging_status} #{scene_delegate}"

sp.pod_target_xcconfig = pod_target_xcconfig
end

s.subspec 'no_pay' do |sp|
sp.dependency 'OpenWeChatSDKNoPay','~> 2.0.2+2'
sp.frameworks = 'CoreGraphics', 'Security', 'WebKit'
sp.libraries = 'c++', 'z', 'sqlite3.0'
if debug_logging
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = '$(inherited) NO_PAY=1 WECHAT_LOGGING=1'
else
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = '$(inherited) NO_PAY=1 WECHAT_LOGGING=0'
end
sp.pod_target_xcconfig = pod_target_xcconfig
pod_target_xcconfig["GCC_PREPROCESSOR_DEFINITIONS"] = "$(inherited) NO_PAY=1 #{logging_status} #{scene_delegate}"
sp.pod_target_xcconfig = pod_target_xcconfig
end

# Flutter.framework does not contain a i386 slice.
Expand Down

0 comments on commit 6c02b1e

Please sign in to comment.