提交 84d6c702 authored 作者: JarvanMo's avatar JarvanMo

Merge no_pay into fluwx

上级 a8bb0384
...@@ -89,8 +89,8 @@ Map loadManifestPlaceholder() { ...@@ -89,8 +89,8 @@ Map loadManifestPlaceholder() {
} }
def logging = fluwx.get("debug_logging") def logging = fluwx.get("debug_logging")
if (logging && logging == "enabled") { if (logging && logging == "true") {
debugLogging = "enabled" debugLogging = "true"
} }
} }
......
...@@ -61,7 +61,7 @@ object WXAPiHandler : ILog { ...@@ -61,7 +61,7 @@ object WXAPiHandler : ILog {
val appInfo = val appInfo =
packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA) packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
val enableLogging = appInfo.metaData.getString("WeChatDebugLogging", "") val enableLogging = appInfo.metaData.getString("WeChatDebugLogging", "")
if (enableLogging == "enabled" && BuildConfig.DEBUG) { if (enableLogging == "true" && BuildConfig.DEBUG) {
startLog() startLog()
} }
} }
...@@ -121,7 +121,7 @@ object WXAPiHandler : ILog { ...@@ -121,7 +121,7 @@ object WXAPiHandler : ILog {
val appInfo = val appInfo =
packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA) packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
val enableLogging = appInfo.metaData.getString("WeChatDebugLogging", "") val enableLogging = appInfo.metaData.getString("WeChatDebugLogging", "")
if (enableLogging == "enabled" && BuildConfig.DEBUG) { if (enableLogging == "true" && BuildConfig.DEBUG) {
startLog() startLog()
} }
} }
......
PODS: PODS:
- Flutter (1.0.0) - Flutter (1.0.0)
- fluwx (0.0.1): - fluwx (0.0.1):
- Flutter
- fluwx/pay (= 0.0.1)
- fluwx/pay (0.0.1):
- Flutter - Flutter
- WechatOpenSDK-XCFramework (~> 2.0.2) - WechatOpenSDK-XCFramework (~> 2.0.2)
- integration_test (0.0.1): - integration_test (0.0.1):
...@@ -26,7 +29,7 @@ EXTERNAL SOURCES: ...@@ -26,7 +29,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluwx: 2f899ad93971ba6d02a6ca1be8b8942a33683668 fluwx: 9c85ece30745e65a5fe02e62ecbfa6b71702105b
integration_test: 13825b8a9334a850581300559b8839134b124670 integration_test: 13825b8a9334a850581300559b8839134b124670
WechatOpenSDK-XCFramework: acdeeda129efbef9532bca8a10c24e1b4b8c7d69 WechatOpenSDK-XCFramework: acdeeda129efbef9532bca8a10c24e1b4b8c7d69
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
06B1F1CBB0F5E70CD45DBD70 /* Runner.entitlements */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
1201E93D5A4AF06F8B2154F7 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; }; 1201E93D5A4AF06F8B2154F7 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
...@@ -141,6 +142,7 @@ ...@@ -141,6 +142,7 @@
97C146F11CF9000F007C117D /* Supporting Files */, 97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
06B1F1CBB0F5E70CD45DBD70 /* Runner.entitlements */,
); );
path = Runner; path = Runner;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -163,7 +165,6 @@ ...@@ -163,7 +165,6 @@
A9DDFA5760AD388C7AE67D68 /* Pods-RunnerTests.release.xcconfig */, A9DDFA5760AD388C7AE67D68 /* Pods-RunnerTests.release.xcconfig */,
3CDE7FB3ADAC9EC781FA9BD4 /* Pods-RunnerTests.profile.xcconfig */, 3CDE7FB3ADAC9EC781FA9BD4 /* Pods-RunnerTests.profile.xcconfig */,
); );
name = Pods;
path = Pods; path = Pods;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
...@@ -225,6 +226,9 @@ ...@@ -225,6 +226,9 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
KnownAssetTags = (
New,
);
LastUpgradeCheck = 1300; LastUpgradeCheck = 1300;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
...@@ -459,6 +463,7 @@ ...@@ -459,6 +463,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 8JJXUFV6F7; DEVELOPMENT_TEAM = 8JJXUFV6F7;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -625,6 +630,7 @@ ...@@ -625,6 +630,7 @@
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 8JJXUFV6F7; DEVELOPMENT_TEAM = 8JJXUFV6F7;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -644,6 +650,7 @@ ...@@ -644,6 +650,7 @@
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 8JJXUFV6F7; DEVELOPMENT_TEAM = 8JJXUFV6F7;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
...@@ -20,10 +22,38 @@ ...@@ -20,10 +22,38 @@
<string>$(FLUTTER_BUILD_NAME)</string> <string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict/>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>weixin</string>
<key>CFBundleURLSchemes</key>
<array>
<string>123456</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>weixin</string>
<string>weixinULAPI</string>
</array>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
...@@ -43,9 +73,5 @@ ...@@ -43,9 +73,5 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict> </dict>
</plist> </plist>
...@@ -93,27 +93,6 @@ class ShareSelectorPage extends StatelessWidget { ...@@ -93,27 +93,6 @@ class ShareSelectorPage extends StatelessWidget {
child: const Text('Get ExtMessage'), child: const Text('Get ExtMessage'),
), ),
), ),
Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () async {
bool? success =
await fluwx.startLog(logLevel: WXLogLevel.normal);
debugPrint('startLog:$success\n');
},
child: const Text('start log'),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () async {
dynamic success = await fluwx.stopLog();
debugPrint('stopLog:$success\n');
},
child: const Text('stop log'),
),
),
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: OutlinedButton( child: OutlinedButton(
......
...@@ -85,8 +85,12 @@ flutter: ...@@ -85,8 +85,12 @@ flutter:
fluwx: fluwx:
app_id: 123456 app_id: 123456
# only debug in debug mode
debug_logging: true
android: android:
interrupt_wx_request: true # interrupt_wx_request: true # default is true
flutter_activity: MainActivity # flutter_activity: MainActivity #Default to launch app's launcher
ios: ios:
uni_link: hello universal_link: https://testdomain.com
# payment is enabled by default
no_pay: true
...@@ -30,7 +30,7 @@ FlutterMethodChannel *channel = nil; ...@@ -30,7 +30,7 @@ FlutterMethodChannel *channel = nil;
channel = [FlutterMethodChannel channel = [FlutterMethodChannel
methodChannelWithName:@"com.jarvanmo/fluwx" methodChannelWithName:@"com.jarvanmo/fluwx"
binaryMessenger:[registrar messenger]]; binaryMessenger:[registrar messenger]];
FluwxPlugin *instance = [[FluwxPlugin alloc] initWithRegistrar:registrar methodChannel:channel]; FluwxPlugin *instance = [[FluwxPlugin alloc] initWithRegistrar:registrar methodChannel:channel];
[registrar addMethodCallDelegate:instance channel:channel]; [registrar addMethodCallDelegate:instance channel:channel];
[[FluwxResponseHandler defaultManager] setMethodChannel:channel]; [[FluwxResponseHandler defaultManager] setMethodChannel:channel];
...@@ -50,6 +50,11 @@ FlutterMethodChannel *channel = nil; ...@@ -50,6 +50,11 @@ FlutterMethodChannel *channel = nil;
channel = flutterMethodChannel; channel = flutterMethodChannel;
[FluwxResponseHandler defaultManager].delegate = self; [FluwxResponseHandler defaultManager].delegate = self;
#ifdef WECHAT_LOGGING
[WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
NSLog(@"Fluwx log: %@", log);
}];
#endif
} }
return self; return self;
} }
...@@ -59,10 +64,6 @@ FlutterMethodChannel *channel = nil; ...@@ -59,10 +64,6 @@ FlutterMethodChannel *channel = nil;
if ([@"registerApp" isEqualToString:call.method]) { if ([@"registerApp" isEqualToString:call.method]) {
[self registerApp:call result:result]; [self registerApp:call result:result];
} else if ([@"startLog" isEqualToString:call.method]) {
[self startLog:call result:result];
} else if ([@"stopLog" isEqualToString:call.method]) {
[self stopLog:call result:result];
} else if ([@"isWeChatInstalled" isEqualToString:call.method]) { } else if ([@"isWeChatInstalled" isEqualToString:call.method]) {
[self checkWeChatInstallation:call result:result]; [self checkWeChatInstallation:call result:result];
} else if ([@"sendAuth" isEqualToString:call.method]) { } else if ([@"sendAuth" isEqualToString:call.method]) {
...@@ -73,10 +74,6 @@ FlutterMethodChannel *channel = nil; ...@@ -73,10 +74,6 @@ FlutterMethodChannel *channel = nil;
[_fluwxAuthHandler stopAuthByQRCode:call result:result]; [_fluwxAuthHandler stopAuthByQRCode:call result:result];
} else if ([@"openWXApp" isEqualToString:call.method]) { } else if ([@"openWXApp" isEqualToString:call.method]) {
result(@([WXApi openWXApp])); result(@([WXApi openWXApp]));
} else if ([@"payWithFluwx" isEqualToString:call.method]) {
[self handlePayment:call result:result];
} else if ([@"payWithHongKongWallet" isEqualToString:call.method]) {
[self handleHongKongWalletPayment:call result:result];
} else if ([@"launchMiniProgram" isEqualToString:call.method]) { } else if ([@"launchMiniProgram" isEqualToString:call.method]) {
[self handleLaunchMiniProgram:call result:result]; [self handleLaunchMiniProgram:call result:result];
} else if ([@"subscribeMsg" isEqualToString:call.method]) { } else if ([@"subscribeMsg" isEqualToString:call.method]) {
...@@ -99,7 +96,21 @@ FlutterMethodChannel *channel = nil; ...@@ -99,7 +96,21 @@ FlutterMethodChannel *channel = nil;
[self checkSupportOpenBusinessView:call result:result]; [self checkSupportOpenBusinessView:call result:result];
} else if([@"openWeChatInvoice" isEqualToString:call.method]) { } else if([@"openWeChatInvoice" isEqualToString:call.method]) {
[self openWeChatInvoice:call result:result]; [self openWeChatInvoice:call result:result];
} else { }
else if ([@"payWithFluwx" isEqualToString:call.method]) {
#ifndef NO_PAY
[self handlePayment:call result:result];
#else
result(@NO);
#endif
} else if ([@"payWithHongKongWallet" isEqualToString:call.method]) {
#ifndef NO_PAY
[self handleHongKongWalletPayment:call result:result];
#else
result(@NO);
#endif
}
else {
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
} }
...@@ -142,29 +153,17 @@ FlutterMethodChannel *channel = nil; ...@@ -142,29 +153,17 @@ FlutterMethodChannel *channel = nil;
} }
BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink]; BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];
result(@(isWeChatRegistered)); #ifdef WECHAT_LOGGING
} if(isWeChatRegistered) {
[WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
- (void)startLog:(FlutterMethodCall *)call result:(FlutterResult)result { NSLog(@"Fluwx Log:%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
NSNumber *typeInt = call.arguments[@"logLevel"]; }];
WXLogLevel logLevel = WXLogLevelDetail;
if ([typeInt isEqualToNumber:@1]) {
logLevel = WXLogLevelDetail;
} else if ([typeInt isEqualToNumber:@0]) {
logLevel = WXLogLevelNormal;
} }
NSLog(@"%@",call.arguments);
[WXApi startLogByLevel:logLevel logBlock:^(NSString * _Nonnull log) {
NSLog(@"%@",log);
}];
result([NSNumber numberWithBool:true]);
}
- (void)stopLog:(FlutterMethodCall *)call result:(FlutterResult)result { #endif
[WXApi stopLog];
result([NSNumber numberWithBool:true]); result(@(isWeChatRegistered));
} }
- (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)result {
......
...@@ -200,32 +200,10 @@ FlutterMethodChannel *fluwxMethodChannel = nil; ...@@ -200,32 +200,10 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
if ([_delegate respondsToSelector:@selector(managerDidRecvInvoiceAuthInsertResponse:)]) { if ([_delegate respondsToSelector:@selector(managerDidRecvInvoiceAuthInsertResponse:)]) {
[_delegate managerDidRecvInvoiceAuthInsertResponse:(WXInvoiceAuthInsertResp *) resp]; [_delegate managerDidRecvInvoiceAuthInsertResponse:(WXInvoiceAuthInsertResp *) resp];
} }
} else if ([resp isKindOfClass:[WXNontaxPayResp class]]) { } else if ([resp isKindOfClass:[WXPayInsuranceResp class]]) {
if ([_delegate respondsToSelector:@selector(managerDidRecvNonTaxpayResponse:)]) {
[_delegate managerDidRecvNonTaxpayResponse:(WXNontaxPayResp *) resp];
}
} else if ([resp isKindOfClass:[WXPayInsuranceResp class]]) {
if ([_delegate respondsToSelector:@selector(managerDidRecvPayInsuranceResponse:)]) { if ([_delegate respondsToSelector:@selector(managerDidRecvPayInsuranceResponse:)]) {
[_delegate managerDidRecvPayInsuranceResponse:(WXPayInsuranceResp *) resp]; [_delegate managerDidRecvPayInsuranceResponse:(WXPayInsuranceResp *) resp];
} }
} else if ([resp isKindOfClass:[PayResp class]]) {
if ([_delegate respondsToSelector:@selector(managerDidRecvPaymentResponse:)]) {
[_delegate managerDidRecvPaymentResponse:(PayResp *) resp];
}
PayResp *payResp = (PayResp *) resp;
NSDictionary *result = @{
description: [FluwxStringUtil nilToEmpty:payResp.description],
errStr: [FluwxStringUtil nilToEmpty:resp.errStr],
errCode: @(payResp.errCode),
type: @(payResp.type),
@"extData": [FluwxStringUtil nilToEmpty:[FluwxDelegate defaultManager].extData],
@"returnKey": [FluwxStringUtil nilToEmpty:payResp.returnKey],
};
[FluwxDelegate defaultManager].extData = nil;
[fluwxMethodChannel invokeMethod:@"onPayResponse" arguments:result];
} else if ([resp isKindOfClass:[WXOpenBusinessWebViewResp class]]) { } else if ([resp isKindOfClass:[WXOpenBusinessWebViewResp class]]) {
WXOpenBusinessWebViewResp *businessResp = (WXOpenBusinessWebViewResp *) resp; WXOpenBusinessWebViewResp *businessResp = (WXOpenBusinessWebViewResp *) resp;
...@@ -269,6 +247,31 @@ FlutterMethodChannel *fluwxMethodChannel = nil; ...@@ -269,6 +247,31 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
[fluwxMethodChannel invokeMethod:@"onOpenBusinessViewResponse" arguments:result]; [fluwxMethodChannel invokeMethod:@"onOpenBusinessViewResponse" arguments:result];
// 相关错误信息 // 相关错误信息
} }
#ifndef NO_PAY
else if ([resp isKindOfClass:[PayResp class]]) {
if ([_delegate respondsToSelector:@selector(managerDidRecvPaymentResponse:)]) {
[_delegate managerDidRecvPaymentResponse:(PayResp *) resp];
}
PayResp *payResp = (PayResp *) resp;
NSDictionary *result = @{
description: [FluwxStringUtil nilToEmpty:payResp.description],
errStr: [FluwxStringUtil nilToEmpty:resp.errStr],
errCode: @(payResp.errCode),
type: @(payResp.type),
@"extData": [FluwxStringUtil nilToEmpty:[FluwxDelegate defaultManager].extData],
@"returnKey": [FluwxStringUtil nilToEmpty:payResp.returnKey],
};
[FluwxDelegate defaultManager].extData = nil;
[fluwxMethodChannel invokeMethod:@"onPayResponse" arguments:result];
} else if ([resp isKindOfClass:[WXNontaxPayResp class]]) {
if ([_delegate respondsToSelector:@selector(managerDidRecvNonTaxpayResponse:)]) {
[_delegate managerDidRecvNonTaxpayResponse:(WXNontaxPayResp *) resp];
}
}
#endif
} }
- (void)onReq:(BaseReq *)req { - (void)onReq:(BaseReq *)req {
......
...@@ -2,6 +2,39 @@ ...@@ -2,6 +2,39 @@
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint fluwx.podspec` to validate before publishing. # Run `pod lib lint fluwx.podspec` to validate before publishing.
# #
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint wechat_kit.podspec` to validate before publishing.
#
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))
library_version = pubspec['version'].gsub('+', '-')
current_dir = Dir.pwd
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 = '0'
if cfg['fluwx'] && cfg['fluwx']['debug_logging'] == 'true'
debug_logging = '1'
end
if cfg['fluwx'] && cfg['fluwx']['ios'] && cfg['fluwx']['ios']['no_pay'] == 'enabled'
fluwx_subspec = 'no_pay'
else
fluwx_subspec = 'pay'
end
Pod::UI.puts "wechatsdk #{fluwx_subspec}"
if cfg['fluwx'] && (cfg['fluwx']['app_id'] && cfg['fluwx']['ios'] && cfg['fluwx']['ios']['universal_link'])
app_id = cfg['fluwx']['app_id']
universal_link = cfg['fluwx']['ios']['universal_link']
system("ruby #{current_dir}/wechat_setup.rb -a #{app_id} -u #{universal_link} -p #{project_dir} -n Runner.xcodeproj")
else
abort("required values:[app_id, universal_link] are missing. Please add them in pubspec.yaml:\nfluwx:\n app_id: ${app id}\n \nios:\nuniversal_link: https://${applinks domain}/universal_link/${example_app}/wechat/\n")
end
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'fluwx' s.name = 'fluwx'
s.version = '0.0.1' s.version = '0.0.1'
...@@ -17,7 +50,25 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca ...@@ -17,7 +50,25 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
s.public_header_files = 'Classes/**/*.h' s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '12.0' s.platform = :ios, '12.0'
s.dependency 'WechatOpenSDK-XCFramework','~> 2.0.2'
s.default_subspec = fluwx_subspec
s.subspec 'pay' do |sp|
sp.dependency 'WechatOpenSDK-XCFramework','~> 2.0.2'
sp.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -ObjC -all_load',
"GCC_PREPROCESSOR_DEFINITIONS_Debug" => "WECHAT_LOGGING=#{debug_logging}"
}
end
s.subspec 'no_pay' do |sp|
sp.vendored_frameworks = 'Frameworks/NoPay/WechatOpenSDK-XCFramework.xcframework'
sp.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -ObjC -all_load',
'GCC_PREPROCESSOR_DEFINITIONS' => 'NO_PAY=1',
"GCC_PREPROCESSOR_DEFINITIONS_Debug" => "WECHAT_LOGGING=#{debug_logging}"
}
end
# Flutter.framework does not contain a i386 slice. # Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
......
#
# Reference documentations
# https://github.com/firebase/flutterfire/blob/master/packages/firebase_crashlytics/firebase_crashlytics/ios/crashlytics_add_upload_symbols
# https://github.com/MagicalWater/Base-APP-Env/blob/master/fastlane/actions/xcode_parse.rb
#
require 'xcodeproj'
require 'plist'
require 'optparse'
require 'uri'
# Dictionary to hold command line arguments
options_dict = {}
# Parse command line arguments into options_dict
OptionParser.new do |options|
options.banner = "Setup the Wechat to an Xcode target."
options.on("-p", "--projectDirectory=DIRECTORY", String, "Directory of the Xcode project") do |dir|
options_dict[:project_dir] = dir
end
options.on("-n", "--projectName=NAME", String, "Name of the Xcode project (ex: Runner.xcodeproj)") do |name|
options_dict[:project_name] = name
end
options.on("-a", "--appId=APPID", String, "App ID for Wechat") do |opts|
options_dict[:app_id] = opts
end
options.on("-u", "--universalLink=UNIVERSALLINK", String, "Universal Link for Wechat") do |opts|
options_dict[:universal_link] = opts
end
end.parse!
# Minimum required arguments are a project directory and project name
unless (options_dict[:project_dir] and options_dict[:project_name])
abort("Must provide a project directory and project name.\n")
end
# Path to the Xcode project to modify
project_path = File.join(options_dict[:project_dir], options_dict[:project_name])
unless (File.exist?(project_path))
abort("Project at #{project_path} does not exist. Please check paths manually.\n");
end
# Actually open and modify the project
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
if target.name == "Runner"
app_id = options_dict[:app_id]
universal_link = options_dict[:universal_link]
applinks = "applinks:#{URI.parse(universal_link).host}"
sectionObject = {}
project.objects.each do |object|
if object.uuid == target.uuid
sectionObject = object
break
end
end
sectionObject.build_configurations.each do |config|
infoplist = config.build_settings["INFOPLIST_FILE"]
if !infoplist
abort("INFOPLIST_FILE is not exist\n")
end
infoplistFile = File.join(options_dict[:project_dir], infoplist)
if !File.exist?(infoplistFile)
abort("#{infoplist} is not exist\n")
end
result = Plist.parse_xml(infoplistFile, marshal: false)
if !result
result = {}
end
urlTypes = result["CFBundleURLTypes"]
if !urlTypes
urlTypes = []
result["CFBundleURLTypes"] = urlTypes
end
isUrlTypeExist = urlTypes.any? { |urlType| urlType["CFBundleURLSchemes"] && (urlType["CFBundleURLSchemes"].include? app_id) }
if !isUrlTypeExist
urlTypes << {
"CFBundleTypeRole": "Editor",
"CFBundleURLName": "weixin",
"CFBundleURLSchemes": [ app_id ]
}
File.write(infoplistFile, Plist::Emit.dump(result))
end
queriesSchemes = result["LSApplicationQueriesSchemes"]
if !queriesSchemes
queriesSchemes = []
result["LSApplicationQueriesSchemes"] = queriesSchemes
end
wechatQueriesSchemes = ["weixin", "weixinULAPI"]
if wechatQueriesSchemes.any? { |queriesScheme| !(queriesSchemes.include? queriesScheme) }
wechatQueriesSchemes.each do |queriesScheme|
if !(queriesSchemes.include? queriesScheme)
queriesSchemes << queriesScheme
end
end
File.write(infoplistFile, Plist::Emit.dump(result))
end
security = result["NSAppTransportSecurity"]
if !security
security = {}
result["NSAppTransportSecurity"] = security
end
if security["NSAllowsArbitraryLoads"] != true
security["NSAllowsArbitraryLoads"] = true
File.write(infoplistFile, Plist::Emit.dump(result))
end
if security["NSAllowsArbitraryLoadsInWebContent"] != true
security["NSAllowsArbitraryLoadsInWebContent"] = true
File.write(infoplistFile, Plist::Emit.dump(result))
end
end
sectionObject.build_configurations.each do |config|
codeSignEntitlements = config.build_settings["CODE_SIGN_ENTITLEMENTS"]
if !codeSignEntitlements
codeSignEntitlements = "Runner/Runner.entitlements"
config.build_settings["CODE_SIGN_ENTITLEMENTS"] = codeSignEntitlements
project.save()
end
codeSignEntitlementsFile = File.join(options_dict[:project_dir], codeSignEntitlements)
if !File.exist?(codeSignEntitlementsFile)
content = Plist::Emit.dump({})
File.write(codeSignEntitlementsFile, content)
end
runnerTargetMainGroup = project.main_group.find_subpath('Runner', false)
isRefExist = runnerTargetMainGroup.files.any? { |file| file.path.include? File.basename(codeSignEntitlementsFile) }
if !isRefExist
runnerTargetMainGroup.new_reference(File.basename(codeSignEntitlementsFile))
project.save()
end
result = Plist.parse_xml(codeSignEntitlementsFile, marshal: false)
if !result
result = {}
end
domains = result["com.apple.developer.associated-domains"]
if !domains
domains = []
result["com.apple.developer.associated-domains"] = domains
end
isApplinksExist = domains.include? applinks
if !isApplinksExist
domains << applinks
File.write(codeSignEntitlementsFile, Plist::Emit.dump(result))
end
end
end
end
...@@ -55,14 +55,6 @@ class Fluwx { ...@@ -55,14 +55,6 @@ class Fluwx {
universalLink: universalLink); universalLink: universalLink);
} }
Future<bool?> startLog({WXLogLevel logLevel = WXLogLevel.unspecific}) {
return FluwxPlatform.instance.startLog(logLevel: logLevel);
}
Future<bool?> stopLog() {
return FluwxPlatform.instance.stopLog();
}
Future<bool> share(WeChatShareModel what) async { Future<bool> share(WeChatShareModel what) async {
return FluwxPlatform.instance.share(what); return FluwxPlatform.instance.share(what);
} }
......
...@@ -152,18 +152,6 @@ class MockFluwxPlatform ...@@ -152,18 +152,6 @@ class MockFluwxPlatform
throw UnimplementedError(); throw UnimplementedError();
} }
@override
Future<bool?> startLog({WXLogLevel logLevel = WXLogLevel.unspecific}) {
// TODO: implement startLog
throw UnimplementedError();
}
@override
Future<bool?> stopLog() {
// TODO: implement stopLog
throw UnimplementedError();
}
@override @override
Future<bool> stopWeChatAuthByQRCode() { Future<bool> stopWeChatAuthByQRCode() {
// TODO: implement stopWeChatAuthByQRCode // TODO: implement stopWeChatAuthByQRCode
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论