From 4c5279c601048346589763ad74b12205d786594a Mon Sep 17 00:00:00 2001 From: Jin857 Date: Thu, 24 Oct 2024 14:43:54 +0800 Subject: [PATCH] =?UTF-8?q?=20=E5=88=9D=E6=AD=A5=E4=B9=A6=E5=86=99=20ios?= =?UTF-8?q?=20=E5=B9=BF=E5=91=8A=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/ios/Podfile | 16 +++-- example/ios/Podfile.lock | 4 +- example/ios/Runner.xcodeproj/project.pbxproj | 62 ++---------------- example/lib/home_page.dart | 1 + example/lib/main.dart | 5 +- ios/Classes/UnionAdSsgfPlugin.swift | 69 ++++++++++++-------- ios/union_ad_ssgf.podspec | 2 +- 7 files changed, 60 insertions(+), 99 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 164df53..a283f73 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -27,14 +27,18 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe flutter_ios_podfile_setup -target 'Runner' do - use_frameworks! - use_modular_headers! +#target 'Runner' do +# use_frameworks! +# use_modular_headers! +# +# flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +# target 'RunnerTests' do +# inherit! :search_paths +# end +#end +target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end end post_install do |installer| diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index d7c1d6a..aae0ec8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -28,8 +28,8 @@ SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 GDTMobSDK: 71e264496ba2ade7d9ce528f4eba1a5424a86654 integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4 - union_ad_ssgf: d55f20ec32899cdfba0eae257331e3f9a01ee366 + union_ad_ssgf: 3f80727f998984d321ad5247ed5aefb073e9488c -PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef +PODFILE CHECKSUM: 0bf49b915f0287a57df9b036ff94509feb1aeb65 COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 26ddfc8..255e383 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -11,11 +11,10 @@ 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 938285D2F874AD5FA6A2B38B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DB0854496C1D03C89077E5F3 /* libPods-Runner.a */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - D5039791B51B519AA9AA2312 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 231BE3EF9C3C195F1B2CF5CB /* Pods_Runner.framework */; settings = {ATTRIBUTES = (Required, ); }; }; - D7B10491D9BF83EA9C67A5DD /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD72858EA9974C84863383E0 /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -44,7 +43,6 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 231BE3EF9C3C195F1B2CF5CB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; @@ -75,7 +73,6 @@ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7F5B62B557E07ABCC2F06213 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - 8A89FE40B60941BB6FEE77D8 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -84,9 +81,7 @@ 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A75FF7AEFE9DC4A76368F956 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - BEC41ED0E4105D18DE067E73 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; - DD72858EA9974C84863383E0 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F3A96745EDBF35DB29565948 /* 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 = ""; }; + DB0854496C1D03C89077E5F3 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -94,7 +89,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D7B10491D9BF83EA9C67A5DD /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -102,7 +96,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D5039791B51B519AA9AA2312 /* Pods_Runner.framework in Frameworks */, + 938285D2F874AD5FA6A2B38B /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -123,9 +117,6 @@ 63E46DBB6AEAA1CBF6915B40 /* Pods-Runner.debug.xcconfig */, A75FF7AEFE9DC4A76368F956 /* Pods-Runner.release.xcconfig */, 7F5B62B557E07ABCC2F06213 /* Pods-Runner.profile.xcconfig */, - F3A96745EDBF35DB29565948 /* Pods-RunnerTests.debug.xcconfig */, - 8A89FE40B60941BB6FEE77D8 /* Pods-RunnerTests.release.xcconfig */, - BEC41ED0E4105D18DE067E73 /* Pods-RunnerTests.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -219,8 +210,7 @@ F69892A496D5EE722DDD9613 /* Frameworks */ = { isa = PBXGroup; children = ( - 231BE3EF9C3C195F1B2CF5CB /* Pods_Runner.framework */, - DD72858EA9974C84863383E0 /* Pods_RunnerTests.framework */, + DB0854496C1D03C89077E5F3 /* libPods-Runner.a */, ); name = Frameworks; sourceTree = ""; @@ -232,7 +222,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - 8593B862DB554AA0EEF8219B /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, 2CC9710731FB2B6942762B9C /* Frameworks */, @@ -258,7 +247,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - D172DAC651DB5E4F39461CF2 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -368,28 +356,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 8593B862DB554AA0EEF8219B /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -405,23 +371,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - D172DAC651DB5E4F39461CF2 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -548,7 +497,6 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F3A96745EDBF35DB29565948 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -566,7 +514,6 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8A89FE40B60941BB6FEE77D8 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -582,7 +529,6 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BEC41ED0E4105D18DE067E73 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index cf6aada..7809b9d 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -20,6 +20,7 @@ class _HomePageState extends State { @override void initState() { super.initState(); + setAdEvent(); } @override diff --git a/example/lib/main.dart b/example/lib/main.dart index 16a4c45..72b2bba 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -23,11 +23,8 @@ class _MyAppState extends State { @override void initState() { super.initState(); - setAdEvent(); init().then((value) { - if (value) { - - } + print("<---- { value : $value } ---->"); }); } diff --git a/ios/Classes/UnionAdSsgfPlugin.swift b/ios/Classes/UnionAdSsgfPlugin.swift index a3009ce..c590e1f 100644 --- a/ios/Classes/UnionAdSsgfPlugin.swift +++ b/ios/Classes/UnionAdSsgfPlugin.swift @@ -1,26 +1,16 @@ -import UIKit import Flutter +import AppTrackingTransparency +import AdSupport + public class UnionAdSsgfPlugin: NSObject, FlutterPlugin ,FlutterStreamHandler{ - static var methodName:String = "union_ad_ssgf_method" - static var eventName :String = "flutter_qq_ads_event" - var splashAd: FAQSplashPage! - var rewardAd: FAQRewardVideoPage! + static var methodName = "union_ad_ssgf_method" + static var eventName = "union_ad_ssgf_event" - // 通知时间 - var eventChannel:FlutterEventChannel? + var splashAd: FAQSplashPage? + var rewardAd: FAQRewardVideoPage? var sink:FlutterEventSink? - public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { - self.sink = events; - return nil; - } - - public func onCancel(withArguments arguments: Any?) -> FlutterError? { - self.sink = nil; - return nil; - } - public static func register(with registrar: FlutterPluginRegistrar) { let methodChannel = FlutterMethodChannel(name: methodName, binaryMessenger: registrar.messenger()); let eventChannel = FlutterEventChannel(name: eventName, binaryMessenger: registrar.messenger()); @@ -58,6 +48,7 @@ public class UnionAdSsgfPlugin: NSObject, FlutterPlugin ,FlutterStreamHandler{ print("App ID: \(appId)") // 初始化插件 let initSuccess = GDTSDKConfig.initWithAppId(appId) + print("初始化插件 initSuccess: \(initSuccess)") result(NSNumber(value: initSuccess)) GDTSDKConfig.start {success, error in // 返回结果 @@ -94,22 +85,44 @@ public class UnionAdSsgfPlugin: NSObject, FlutterPlugin ,FlutterStreamHandler{ public func showSplashAd(call: FlutterMethodCall, result: FlutterResult) { // 初始化 FAQSplashPage 实例 self.splashAd = FAQSplashPage() - - // 调用 showAd 方法 - self.splashAd.showAd(call: call, eventSink: self.sink!) - - // 返回结果 - result(NSNumber(value: true)) - + if(self.sink != nil){ + self.splashAd?.showAd(call: call, eventSink: self.sink!) + result(true) + }else{ + result(NSNumber(value: false)) + } } // 激励广告 public func showRewardVideoAd(call: FlutterMethodCall, result: FlutterResult) { // 初始化 FAQRewardVideoPage 实例 self.rewardAd = FAQRewardVideoPage(); - // 调用 showAd 方法 - self.rewardAd.showAd(call: call, eventSink: self.sink!) - // 返回结果 - result(NSNumber(value: true)) + if(self.sink != nil){ + self.rewardAd?.showAd(call: call, eventSink: self.sink!) + result(NSNumber(value: true)) + }else{ + result(NSNumber(value: false)) + } } + + // 设置事件接收器 + public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { + print("onListen ------------------>>>>>>") + self.sink = events + return nil + } + + // 清空事件接收器 + public func onCancel(withArguments arguments: Any?) -> FlutterError? { + print("onCancel ------------------>>>>>>") + self.sink = nil; + return nil; + } + + // 添加事件 + private func addEvent(_ event: NSObject) { + print("addEvent ------------------>>>>>>") + self.sink?(event) + } + } diff --git a/ios/union_ad_ssgf.podspec b/ios/union_ad_ssgf.podspec index b6c0e63..f35d9de 100644 --- a/ios/union_ad_ssgf.podspec +++ b/ios/union_ad_ssgf.podspec @@ -56,5 +56,5 @@ Pod::Spec.new do |s| # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - # s.swift_version = '5.0' + s.swift_version = '5.0' end