初步添加 ios 广告逻辑

This commit is contained in:
Jin857 2024-10-23 17:03:18 +08:00
parent 578c1974c5
commit 2345b719dd
29 changed files with 946 additions and 67 deletions

View File

@ -134,7 +134,6 @@ class PluginDelegate(var activity: Activity, bind: FlutterPluginBinding) :
override fun onStartSuccess() {
Log.e("gdt onStartSuccess", "加载成功")
}
override fun onStartFailed(e: Exception) {
Log.e("gdt onStartFailed:", e.toString())
}

View File

@ -25,20 +25,29 @@ import com.qq.e.comm.util.AdError
*/
class AdSplashActivity() : AppCompatActivity(), SplashADListener {
private val TAG = AdSplashActivity::class.java.getSimpleName()
// 广告容器
/**
* 广告容器
*/
private var ad_container: FrameLayout? = null
// 自定义品牌 logo
/**
* 自定义品牌 logo
*/
private var ad_logo: AppCompatImageView? = null
// 广告位 id
/**
* 广告位 id
*/
private var posId: String? = null
// 是否全屏
/**
* 是否全屏
*/
private var isFullScreen = false
// 开屏广告
/**
* 开屏广告
*/
private var splashAD: SplashAD? = null
override fun onCreate(savedInstanceState: Bundle?) {
@ -84,12 +93,18 @@ class AdSplashActivity() : AppCompatActivity(), SplashADListener {
}
}
/**
* 广告关闭时调用可能是用户关闭或者展示时间到此时一般需要跳过开屏的 Activity进入应用内容页面
*/
override fun onADDismissed() {
Log.d(TAG, "onADDismissed")
finishPage()
AdEventHandler.getInstance()?.sendEvent(AdEvent(posId, "", 1, AdEventAction.onAdClosed));
}
/**
* 广告加载或展示过程中出错AdError中包含了错误码和错误描述具体错误码内容可参考错误码部分
*/
override fun onNoAD(adError: AdError) {
Log.d(TAG, "onNoAD adError:" + adError.errorMsg);
finishPage()
@ -97,25 +112,41 @@ class AdSplashActivity() : AppCompatActivity(), SplashADListener {
.sendEvent(AdErrorEvent(posId, "", 1, adError.errorCode, adError.errorMsg));
}
/**
* 广告成功展示时调用成功展示不等于有效展示比如广告容器高度不够
*/
override fun onADPresent() {
Log.d(TAG, "onADPresent")
AdEventHandler.getInstance()!!.sendEvent(AdEvent(posId, "", 1, AdEventAction.onAdPresent))
}
/**
* 广告被点击时调用不代表满足计费条件如点击时网络异常
*/
override fun onADClicked() {
Log.d(TAG, "onADClicked")
AdEventHandler.getInstance()!!.sendEvent(AdEvent(posId, "", 1, AdEventAction.onAdClicked))
}
/**
* 倒计时回调返回广告还将被展示的剩余时间单位是 ms
*/
override fun onADTick(millisUntilFinished: Long) {
Log.d(TAG, "onADTick millisUntilFinished$millisUntilFinished");
}
/**
* 广告曝光时调用
*/
override fun onADExposure() {
Log.d(TAG, "onADExposure")
AdEventHandler.getInstance()!!.sendEvent(AdEvent(posId, "", 1, AdEventAction.onAdExposure))
}
/**
* 广告加载成功的回调在fetchAdOnly的情况下表示广告拉取成功可以显示了
* 广告需要在SystemClock.elapsedRealtime <expireTimestamp前展示否则在showAd时会返回广告超时错误
*/
override fun onADLoaded(expireTimestamp: Long) {
Log.d(TAG, "onADLoaded expireTimestamp$expireTimestamp")
AdEventHandler.getInstance()!!.sendEvent(AdEvent(posId, "", 1, AdEventAction.onAdLoaded))
@ -146,7 +177,6 @@ class AdSplashActivity() : AppCompatActivity(), SplashADListener {
/**
* 获取图片资源的id
*
* @param resName 资源名称不带后缀
* @return 返回资源id
*/

View File

@ -15,7 +15,6 @@ import java.util.Locale
*/
class RewardVideoPage() : BaseAdPage(), RewardVideoADListener {
private val TAG = RewardVideoPage::class.java.getSimpleName()
/**
* 激励广告对象
*/
@ -31,6 +30,10 @@ class RewardVideoPage() : BaseAdPage(), RewardVideoADListener {
*/
private lateinit var userId: String
/**
* 加载激励视频广告加载成功则调用回调RewardVideoADListener.onADLoad()
* 加载失败则会调用RewardVideoADListener.onError(AdError error)
*/
override fun loadAd(call: MethodCall?) {
/**
* 获取对应参数
@ -59,9 +62,9 @@ class RewardVideoPage() : BaseAdPage(), RewardVideoADListener {
* 广告加载成功可在此回调后进行广告展示
**/
override fun onADLoad() {
Log.i(TAG, "onADLoad");
rewardVideoAD.showAD();
sendEvent(AdEventAction.onAdLoaded);
Log.i(TAG, "onADLoad")
rewardVideoAD.showAD()
sendEvent(AdEventAction.onAdLoaded)
}
/**
@ -101,23 +104,23 @@ class RewardVideoPage() : BaseAdPage(), RewardVideoADListener {
* 激励视频广告被点击
*/
override fun onADClick() {
Log.i(TAG, "onADClick");
sendEvent(AdEventAction.onAdClicked);
Log.i(TAG, "onADClick")
sendEvent(AdEventAction.onAdClicked)
}
/**
* 激励视频广告被关闭
*/
override fun onVideoComplete() {
Log.i(TAG, "onVideoComplete");
Log.i(TAG, "onVideoComplete")
}
/**
* 激励视频广告被关闭
*/
override fun onADClose() {
Log.i(TAG, "onADClose");
sendEvent(AdEventAction.onAdClosed);
Log.i(TAG, "onADClose")
sendEvent(AdEventAction.onAdClosed)
}
/**

View File

@ -25,6 +25,7 @@ if (flutterVersionName == null) {
android {
namespace = "com.example.union_ad_ssgf_example"
// namespace = "com.zero.flutter_qq_ads_example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
@ -35,7 +36,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.union_ad_ssgf_example"
// applicationId = "com.example.union_ad_ssgf_example"
applicationId = "com.banjixiaoguanjia.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = flutter.minSdkVersion
@ -44,11 +46,25 @@ android {
versionName = flutterVersionName
}
buildTypes {
//
signingConfigs {
release {
storeFile new File("${project.projectDir}/keystore/flutterads_key.jks")
storePassword "FlutterAds"
keyAlias 'FlutterAdsQQ'
keyPassword "FlutterAds"
// 2
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
signingConfig signingConfigs.release
}
}
}

View File

@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="union_ad_ssgf_example"
android:label="FlutterAds"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
example/images/pro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

35
example/ios/Podfile.lock Normal file
View File

@ -0,0 +1,35 @@
PODS:
- Flutter (1.0.0)
- GDTMobSDK (4.15.10)
- integration_test (0.0.1):
- Flutter
- union_ad_ssgf (0.0.1):
- Flutter
- GDTMobSDK (~> 4.15.10)
DEPENDENCIES:
- Flutter (from `Flutter`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- union_ad_ssgf (from `.symlinks/plugins/union_ad_ssgf/ios`)
SPEC REPOS:
trunk:
- GDTMobSDK
EXTERNAL SOURCES:
Flutter:
:path: Flutter
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
union_ad_ssgf:
:path: ".symlinks/plugins/union_ad_ssgf/ios"
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
GDTMobSDK: 71e264496ba2ade7d9ce528f4eba1a5424a86654
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
union_ad_ssgf: d55f20ec32899cdfba0eae257331e3f9a01ee366
PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef
COCOAPODS: 1.15.2

View File

@ -14,6 +14,8 @@
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 */
@ -42,12 +44,38 @@
/* Begin PBXFileReference section */
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>"; };
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 = "<group>"; };
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 = "<group>"; };
3C501DB22CC78D0000708F60 /* GDTAdParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTAdParams.h; sourceTree = "<group>"; };
3C501DB32CC78D0000708F60 /* GDTAdProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTAdProtocol.h; sourceTree = "<group>"; };
3C501DB42CC78D0000708F60 /* GDTAdTestSetting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTAdTestSetting.h; sourceTree = "<group>"; };
3C501DB52CC78D0000708F60 /* GDTLoadAdParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTLoadAdParams.h; sourceTree = "<group>"; };
3C501DB62CC78D0000708F60 /* GDTLogoView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTLogoView.h; sourceTree = "<group>"; };
3C501DB72CC78D0000708F60 /* GDTMediaView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTMediaView.h; sourceTree = "<group>"; };
3C501DB82CC78D0000708F60 /* GDTNativeExpressAd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTNativeExpressAd.h; sourceTree = "<group>"; };
3C501DB92CC78D0000708F60 /* GDTNativeExpressAdView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTNativeExpressAdView.h; sourceTree = "<group>"; };
3C501DBA2CC78D0000708F60 /* GDTPrivacyConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTPrivacyConfiguration.h; sourceTree = "<group>"; };
3C501DBB2CC78D0000708F60 /* GDTRewardVideoAd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTRewardVideoAd.h; sourceTree = "<group>"; };
3C501DBC2CC78D0000708F60 /* GDTSDKConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTSDKConfig.h; sourceTree = "<group>"; };
3C501DBD2CC78D0000708F60 /* GDTSDKDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTSDKDefines.h; sourceTree = "<group>"; };
3C501DBE2CC78D0000708F60 /* GDTServerSideVerificationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTServerSideVerificationOptions.h; sourceTree = "<group>"; };
3C501DBF2CC78D0000708F60 /* GDTSplashAd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTSplashAd.h; sourceTree = "<group>"; };
3C501DC02CC78D0000708F60 /* GDTUnifiedBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTUnifiedBannerView.h; sourceTree = "<group>"; };
3C501DC12CC78D0000708F60 /* GDTUnifiedInterstitialAd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTUnifiedInterstitialAd.h; sourceTree = "<group>"; };
3C501DC22CC78D0000708F60 /* GDTUnifiedNativeAd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTUnifiedNativeAd.h; sourceTree = "<group>"; };
3C501DC32CC78D0000708F60 /* GDTUnifiedNativeAdDataObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTUnifiedNativeAdDataObject.h; sourceTree = "<group>"; };
3C501DC42CC78D0000708F60 /* GDTUnifiedNativeAdView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTUnifiedNativeAdView.h; sourceTree = "<group>"; };
3C501DC52CC78D0000708F60 /* GDTVideoAdReporter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTVideoAdReporter.h; sourceTree = "<group>"; };
3C501DC62CC78D0000708F60 /* GDTVideoConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GDTVideoConfig.h; sourceTree = "<group>"; };
3C501DC72CC78D0000708F60 /* libGDTMobSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGDTMobSDK.a; sourceTree = "<group>"; };
63E46DBB6AEAA1CBF6915B40 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -55,13 +83,26 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
2CC9710731FB2B6942762B9C /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D7B10491D9BF83EA9C67A5DD /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D5039791B51B519AA9AA2312 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -76,6 +117,57 @@
path = RunnerTests;
sourceTree = "<group>";
};
354765ABE2C866D39CE73987 /* Pods */ = {
isa = PBXGroup;
children = (
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 = "<group>";
};
3C501DC82CC78D0000708F60 /* lib */ = {
isa = PBXGroup;
children = (
3C501DB22CC78D0000708F60 /* GDTAdParams.h */,
3C501DB32CC78D0000708F60 /* GDTAdProtocol.h */,
3C501DB42CC78D0000708F60 /* GDTAdTestSetting.h */,
3C501DB52CC78D0000708F60 /* GDTLoadAdParams.h */,
3C501DB62CC78D0000708F60 /* GDTLogoView.h */,
3C501DB72CC78D0000708F60 /* GDTMediaView.h */,
3C501DB82CC78D0000708F60 /* GDTNativeExpressAd.h */,
3C501DB92CC78D0000708F60 /* GDTNativeExpressAdView.h */,
3C501DBA2CC78D0000708F60 /* GDTPrivacyConfiguration.h */,
3C501DBB2CC78D0000708F60 /* GDTRewardVideoAd.h */,
3C501DBC2CC78D0000708F60 /* GDTSDKConfig.h */,
3C501DBD2CC78D0000708F60 /* GDTSDKDefines.h */,
3C501DBE2CC78D0000708F60 /* GDTServerSideVerificationOptions.h */,
3C501DBF2CC78D0000708F60 /* GDTSplashAd.h */,
3C501DC02CC78D0000708F60 /* GDTUnifiedBannerView.h */,
3C501DC12CC78D0000708F60 /* GDTUnifiedInterstitialAd.h */,
3C501DC22CC78D0000708F60 /* GDTUnifiedNativeAd.h */,
3C501DC32CC78D0000708F60 /* GDTUnifiedNativeAdDataObject.h */,
3C501DC42CC78D0000708F60 /* GDTUnifiedNativeAdView.h */,
3C501DC52CC78D0000708F60 /* GDTVideoAdReporter.h */,
3C501DC62CC78D0000708F60 /* GDTVideoConfig.h */,
3C501DC72CC78D0000708F60 /* libGDTMobSDK.a */,
);
path = lib;
sourceTree = "<group>";
};
3C501DC92CC78D0000708F60 /* GDTMobSDK */ = {
isa = PBXGroup;
children = (
3C501DC82CC78D0000708F60 /* lib */,
);
name = GDTMobSDK;
path = Pods/GDTMobSDK;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@ -90,10 +182,13 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
3C501DC92CC78D0000708F60 /* GDTMobSDK */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
354765ABE2C866D39CE73987 /* Pods */,
F69892A496D5EE722DDD9613 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -121,6 +216,15 @@
path = Runner;
sourceTree = "<group>";
};
F69892A496D5EE722DDD9613 /* Frameworks */ = {
isa = PBXGroup;
children = (
231BE3EF9C3C195F1B2CF5CB /* Pods_Runner.framework */,
DD72858EA9974C84863383E0 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -128,8 +232,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
8593B862DB554AA0EEF8219B /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
2CC9710731FB2B6942762B9C /* Frameworks */,
);
buildRules = (
);
@ -145,12 +251,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
4AC0BF70F33FC1FE2306EF33 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
D172DAC651DB5E4F39461CF2 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -236,7 +344,51 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
4AC0BF70F33FC1FE2306EF33 /* [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-Runner-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;
};
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;
@ -253,6 +405,23 @@
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 */
@ -379,6 +548,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F3A96745EDBF35DB29565948 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -396,6 +566,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8A89FE40B60941BB6FEE77D8 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -411,6 +582,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEC41ED0E4105D18DE067E73 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;

View File

@ -4,4 +4,10 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/GDTMobSDK">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -2,7 +2,7 @@ import Flutter
import UIKit
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="139" y="-2"/>
</scene>
</scenes>
</document>

View File

@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Union Ad Ssgf</string>
<string>UnionAdSsgf</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@ -24,6 +24,13 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSUserTrackingUsageDescription</key>
<string>为了向您提供更优质、安全的个性化服务及内容,需要您允许使用相关权限</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
@ -41,6 +48,8 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>

View File

@ -1 +1,8 @@
#import "GeneratedPluginRegistrant.h"
#import "GDTNativeExpressAdView.h"
#import "GDTNativeExpressAd.h"
#import "GDTSplashAd.h"
#import "GDTRewardVideoAd.h"
#import "GDTSDKConfig.h"

View File

@ -33,28 +33,28 @@ class _HomePageState extends State<HomePage> {
padding: const EdgeInsets.all(10),
child: Column(
children: [
SizedBox(height: 10),
const SizedBox(height: 10),
Text('Result: $_result'),
SizedBox(height: 10),
const SizedBox(height: 10),
Text('onAdEvent: $_adEvent'),
SizedBox(height: 20),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
child: Text('初始化'),
child: const Text('初始化'),
onPressed: () {},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('请求跟踪授权'),
child: const Text('请求跟踪授权'),
onPressed: () {
requestIDFA();
},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('个性化广告'),
child: const Text('个性化广告'),
onPressed: () {
setPersonalizedAd(1);
},
@ -65,14 +65,12 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
child: Text('开屏(Logo2)'),
onPressed: () {
showSplashAd(AdsConfig.logo2);
},
child: const Text('开屏(Logo2)'),
onPressed: () {},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('开屏(全屏)'),
child: const Text('开屏(全屏)'),
onPressed: () {
showSplashAd();
setState(() {});
@ -84,14 +82,14 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
child: Text('插屏广告'),
child: const Text('插屏广告'),
onPressed: () {
showInterstitialAd(AdsConfig.interstitialId);
},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('插全屏广告'),
child: const Text('插全屏广告'),
onPressed: () {
showInterstitialAd(
AdsConfig.interstitialFullScreenVideoId,
@ -105,7 +103,7 @@ class _HomePageState extends State<HomePage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
child: Text('插屏激励'),
child: const Text('插屏激励'),
onPressed: () {
showInterstitialAd(
AdsConfig.interstitialRewardVideoId,
@ -114,27 +112,26 @@ class _HomePageState extends State<HomePage> {
);
},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('激励视频'),
child: const Text('激励视频'),
onPressed: () {
showRewardVideoAd();
},
),
],
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
child: Text('信息流'),
child: const Text('信息流'),
onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => FeedPage(),
// ));
// builder: (context) => FeedPage(),));
},
),
SizedBox(height: 20),
const SizedBox(height: 20),
const Center(child: Text('👇🏻 Banner 广告 👇🏻')),
const SizedBox(height: 10),
// AdBannerWidget(
@ -144,7 +141,7 @@ class _HomePageState extends State<HomePage> {
// interval: 0,
// show: true,
// ),
SizedBox(height: 10),
const SizedBox(height: 10),
],
),
),

View File

@ -3,6 +3,7 @@ description: "Demonstrates how to use the union_ad_ssgf plugin."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.001+001
environment:
sdk: '>=3.4.4 <4.0.0'
@ -28,6 +29,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.6
loadany: ^1.0.0
dev_dependencies:
integration_test:
@ -52,7 +54,9 @@ flutter:
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- images/
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg

View File

@ -0,0 +1,32 @@
//
// FAQAdErrorEvent.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import Foundation
// 广
class FAQAdErrorEvent: FAQAdEvent {
//
var errCode: NSNumber
//
var errMsg: String
// 广
init(adId: String, errCode: NSNumber, errMsg: String) {
self.errCode = errCode
self.errMsg = errMsg
super.init(adId: adId, action: "onAdError") // onAdError
}
//
override func toMap() -> [String: Any] {
var errData = super.toMap() //
errData["errCode"] = errCode //
errData["errMsg"] = errMsg //
return errData //
}
}

View File

@ -0,0 +1,27 @@
//
// FAQAdEvent.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import Foundation
//
class FAQAdEvent {
// 广 id
var adId: String
//
var action: String
// - 广
init(adId: String, action: String) {
self.adId = adId
self.action = action
}
// Map
func toMap() -> [String: Any] {
return ["adId": adId, "action": action]
}
}

View File

@ -0,0 +1,43 @@
//
// FAQAdEventAction.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import Foundation
//广
// 广
let onAdError = "onAdError"
// 广
let onAdLoaded = "onAdLoaded"
// 广
let onAdPresent = "onAdPresent"
// 广
let onAdExposure = "onAdExposure"
// 广
let onAdClosed = "onAdClosed"
// 广
let onAdClicked = "onAdClicked"
// 广
let onAdSkip = "onAdSkip"
// 广
let onAdComplete = "onAdComplete"
// 广
let onAdReward = "onAdReward"
// 广
class FAQAdEventAction: NSObject {
// 广
}

View File

@ -0,0 +1,36 @@
//
// FAQAdRewardEvent.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import Foundation
// 广
class FAQAdRewardEvent: FAQAdEvent {
// id
var transId: String
//
var customData: String
//
var userId: String
// 广
init(adId: String, transId: String, customData: String, userId: String) {
self.transId = transId
self.customData = customData
self.userId = userId
super.init(adId: adId, action: onAdReward) // onAdReward
}
//
override func toMap() -> [String: Any] {
var errData = super.toMap() //
errData["transId"] = transId // transId
errData["customData"] = customData // customData
errData["userId"] = userId // userId
return errData //
}
}

View File

@ -0,0 +1,78 @@
//
// FAQBaseAdPage.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import Flutter
import UIKit
// - 广
class FAQBaseAdPage: NSObject {
let kPosId = "posId"
var posId: String!
var eventSink: FlutterEventSink?
var mainWin: UIWindow?
var rootController: UIViewController?
var width: CGFloat = 0
var height: CGFloat = 0
// 广
func addAdEvent(_ event: FAQAdEvent) {
if let eventSink = self.eventSink {
eventSink(event.toMap())
}
}
// 广
func showAd(call: FlutterMethodCall, eventSink: @escaping FlutterEventSink) {
guard let arguments = call.arguments as? [String: Any],
let posId = arguments[kPosId] as? String
else {
return
}
self.posId = posId
self.eventSink = eventSink
// window
self.mainWin = UIApplication.shared.keyWindow
// rootViewController
self.rootController = self.mainWin?.rootViewController
//
let size = UIScreen.main.bounds.size
self.width = size.width
self.height = size.height
loadAd(call: call)
}
// 广
func loadAd(call: FlutterMethodCall) {
print(#function) // 使 Swift print NSLog
}
// 广
func sendEvent(_ event: FAQAdEvent) {
if let eventSink = self.eventSink {
eventSink(event.toMap())
}
}
// 广
func sendEventAction(_ action: String) {
let event = FAQAdEvent(adId: self.posId, action: action)
sendEvent(event)
}
// 广
func sendErrorEvent(errCode: Int, errMsg: String) {
let event = FAQAdErrorEvent(
adId: self.posId, errCode: NSNumber(value: errCode), errMsg: errMsg)
sendEvent(event)
}
}

View File

@ -0,0 +1,108 @@
//
// FAQRewardVideoPage.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import UIKit
import Flutter
//
class FAQRewardVideoPage: FAQBaseAdPage, GDTRewardedVideoAdDelegate {
// 广
var rvad: GDTRewardVideoAd?
//
var customData: String?
//
var userId: String?
// 广
override func loadAd(call: FlutterMethodCall) {
guard let arguments = call.arguments as? [String: Any],
let customData = arguments["customData"] as? String,
let userId = arguments["userId"] as? String,
let playMuted = arguments["playMuted"] as? Bool else {
return
}
self.customData = customData
self.userId = userId
// 广
self.rvad = GDTRewardVideoAd(placementId: self.posId)
self.rvad?.delegate = self
self.rvad?.videoMuted = playMuted
// serverSideVerificationOptions
let ssv = GDTServerSideVerificationOptions()
ssv.userIdentifier = self.userId
ssv.customRewardString = self.customData
self.rvad?.serverSideVerificationOptions = ssv
self.rvad?.load()
}
// MARK: - GDTRewardVideoAdDelegate
func gdt_rewardVideoAdDidLoad(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
if let controller = UIApplication.shared.keyWindow?.rootViewController {
self.rvad?.show(fromRootViewController: controller)
// 广
self.sendEventAction(onAdLoaded)
}
}
func gdt_rewardVideoAdVideoDidLoad(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
}
func gdt_rewardVideoAdWillVisible(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
// 广
self.sendEventAction(onAdPresent)
}
func gdt_rewardVideoAdDidExposed(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
print("广告已曝光")
// 广
self.sendEventAction(onAdExposure)
}
func gdt_rewardVideoAdDidClose(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
print("广告已关闭")
// 广
self.sendEventAction(onAdClosed)
}
func gdt_rewardVideoAdDidClicked(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
print("广告已点击")
// 广
self.sendEventAction(onAdClicked)
}
func gdt_rewardVideoAd(_ rewardedVideoAd: GDTRewardVideoAd, didFailWithError error: Error) {
print(#function)
print("ERROR: \(error.localizedDescription)")
// 广
self.sendErrorEvent(errCode: (error as NSError).code, errMsg: error.localizedDescription)
}
func gdt_rewardVideoAdDidRewardEffective(_ rewardedVideoAd: GDTRewardVideoAd, info: [AnyHashable: Any]) {
print(#function)
if let transId = info["GDT_TRANS_ID"] as? String {
print("播放达到激励条件 transid: \(transId)")
//
let event = FAQAdRewardEvent(adId: self.posId, transId: transId, customData: self.customData!, userId: self.userId!)
self.sendEvent(event)
}
}
func gdt_rewardVideoAdDidPlayFinish(_ rewardedVideoAd: GDTRewardVideoAd) {
print(#function)
print("视频播放结束")
}
}

View File

@ -0,0 +1,136 @@
//
// FAQSplashPage.swift
// Pods
//
// Created by Jin on 10/23/24.
//
import UIKit
import Flutter
class FAQSplashPage: FAQBaseAdPage, GDTSplashAdDelegate {
var splashAd: GDTSplashAd!
var fullScreenAd: Bool = false
var bottomView: UIView?
// 广
override func loadAd(call: FlutterMethodCall) {
// logo fetchDelay
guard let arguments = call.arguments as? [String: Any],
let logo = arguments["logo"] as? String,
let fetchDelay = arguments["fetchDelay"] as? CGFloat
else {
return
}
// logo
self.fullScreenAd = logo.isEmpty
// 广
self.splashAd = GDTSplashAd(placementId: self.posId)
// FAQSplashPage
self.splashAd.delegate = self
//
self.splashAd.fetchDelay = fetchDelay
// 广
if self.fullScreenAd {
self.splashAd.loadFullScreenAd()
} else {
// 广
self.splashAd.load()
// logo
self.bottomView = nil
let size = UIScreen.main.bounds.size
let width = size.width
// 15% logo
let height: CGFloat = 112.5
self.bottomView = UIView(frame: CGRect(x: 0, y: 0, width: width, height: height))
self.bottomView?.backgroundColor = .white
if let logoImage = UIImage(named: logo) {
let logoView = UIImageView(image: logoImage)
logoView.frame = CGRect(x: 0, y: 0, width: width, height: height)
logoView.contentMode = .center
logoView.center = self.bottomView!.center
self.bottomView?.addSubview(logoView)
}
}
}
// MARK: - GDTSplashAdDelegate
func splashAdDidLoad(_ splashAd: GDTSplashAd) {
print("splashAdDidLoad")
if let mainWindow = UIApplication.shared.keyWindow {
// 广
if self.fullScreenAd {
self.splashAd.showFullScreenAd(in: mainWindow, withLogoImage: nil, skip: nil)
} else {
// 广
self.splashAd.show(in: mainWindow, withBottomView: self.bottomView, skip: nil)
}
// 广
sendEventAction("onAdLoaded")
}
}
func splashAdSuccessPresentScreen(_ splashAd: GDTSplashAd) {
print(#function)
// 广
sendEventAction("onAdPresent")
}
func splashAdFail(toPresent splashAd: GDTSplashAd, withError error: Error) {
print("\( #function) \(error.localizedDescription)")
// 广
sendErrorEvent(error._code, withErrMsg: error.localizedDescription)
}
func splashAdExposured(_ splashAd: GDTSplashAd) {
print(#function)
// 广
sendEventAction("onAdExposure")
}
func splashAdClicked(_ splashAd: GDTSplashAd) {
print(#function)
// 广
sendEventAction("onAdClicked")
}
func splashAdApplicationWillEnterBackground(_ splashAd: GDTSplashAd) {
print(#function)
}
func splashAdWillClosed(_ splashAd: GDTSplashAd) {
print(#function)
}
func splashAdClosed(_ splashAd: GDTSplashAd) {
print(#function)
self.splashAd = nil
// 广
sendEventAction("onAdClosed")
}
func splashAdWillPresentFullScreenModal(_ splashAd: GDTSplashAd) {
print(#function)
}
func splashAdDidPresentFullScreenModal(_ splashAd: GDTSplashAd) {
print(#function)
}
func splashAdWillDismissFullScreenModal(_ splashAd: GDTSplashAd) {
print(#function)
}
func splashAdDidDismissFullScreenModal(_ splashAd: GDTSplashAd) {
print(#function)
}
//
private func sendErrorEvent(_ code: Int, withErrMsg msg: String) {
//
print("Error sent: \(code); message: \(msg)")
}
}

View File

@ -0,0 +1,5 @@
#import <GDTMobSDK/GDTNativeExpressAdView.h>
#import <GDTMobSDK/GDTNativeExpressAd.h>
#import <GDTMobSDK/GDTRewardVideoAd.h>
#import <GDTMobSDK/GDTSplashAd.h>
#import <GDTMobSDK/GDTSDKConfig.h>

View File

@ -1,19 +1,115 @@
import Flutter
import UIKit
import Flutter
public class UnionAdSsgfPlugin: NSObject, FlutterPlugin {
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!
//
var eventChannel:FlutterEventChannel?
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 channel = FlutterMethodChannel(name: "union_ad_ssgf_method", binaryMessenger: registrar.messenger())
let instance = UnionAdSsgfPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
let methodChannel = FlutterMethodChannel(name: methodName, binaryMessenger: registrar.messenger());
let eventChannel = FlutterEventChannel(name: eventName, binaryMessenger: registrar.messenger());
let instance = UnionAdSsgfPlugin();
registrar.addMethodCallDelegate(instance, channel: methodChannel);
eventChannel.setStreamHandler(instance);
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getPlatformVersion":
result("iOS " + UIDevice.current.systemVersion)
getPlatformVersion(call: call, result: result)
case "initAd": //
initAd(call:call, result: result);
case "setPersonalizedState": // 广
setPersonalizedState(call:call, result: result);
case "showSplashAd": // 广
showSplashAd(call:call, result: result);
case "showRewardVideoAd": // 广
showRewardVideoAd(call:call, result: result);
default:
result(FlutterMethodNotImplemented)
}
}
//
public func getPlatformVersion(call: FlutterMethodCall, result: @escaping FlutterResult) {
result("iOS " + UIDevice.current.systemVersion)
}
// 广
public func initAd(call: FlutterMethodCall, result: @escaping FlutterResult) {
if let arguments = call.arguments as? [String: Any],
let appId = arguments["appId"] as? String {
print("App ID: \(appId)")
//
let initSuccess = GDTSDKConfig.initWithAppId(appId)
result(NSNumber(value: initSuccess))
GDTSDKConfig.start {success, error in
//
result(true)
if success {
result(NSNumber(value: true))
} else {
result(NSNumber(value: false))
if let error = error {
print("FlutterQqAdsPlugin initAd error: \(error.localizedDescription)")
}
}
}
} else {
print("appId not found or invalid type.")
result(NSNumber(value: false)) // appId
}
}
// 广
public func setPersonalizedState(call: FlutterMethodCall, result: @escaping FlutterResult) {
if let arguments = call.arguments as? [String: Any],
let state = arguments["state"] as? Int {
print("Set State : \(state)")
GDTSDKConfig.setPersonalizedState(state)
result(NSNumber(value: true))
} else {
print("appId not found or invalid type.")
result(NSNumber(value: false)) // appId
}
}
// 广
public func showSplashAd(call: FlutterMethodCall, result: FlutterResult) {
// FAQSplashPage
self.splashAd = FAQSplashPage()
// showAd
self.splashAd.showAd(call: call, eventSink: self.sink!)
//
result(NSNumber(value: true))
}
// 广
public func showRewardVideoAd(call: FlutterMethodCall, result: FlutterResult) {
// FAQRewardVideoPage
self.rewardAd = FAQRewardVideoPage();
// showAd
self.rewardAd.showAd(call: call, eventSink: self.sink!)
//
result(NSNumber(value: true))
}
}

View File

@ -3,21 +3,58 @@
# Run `pod lib lint union_ad_ssgf.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
# 库的名称
s.name = 'union_ad_ssgf'
# 库的版本号
s.version = '0.0.1'
s.summary = 'A new Flutter project.'
# 库的简要描述
s.summary = '一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇)'
# 库的详细描述
s.description = <<-DESC
A new Flutter project.
一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇).
DESC
s.homepage = 'http://example.com'
# 库的许可证类型和文件路径
s.license = { :file => '../LICENSE' }
# 库的作者姓名和电子邮件
s.author = { 'Your Company' => 'email@example.com' }
# 库的源代码位置可以是Git仓库的URL和标签或分支
s.source = { :path => '.' }
# 包含库的主要源代码文件
s.source_files = 'Classes/**/*'
# s.public_header_files和s.private_header_files分别指定公共和私有头文件。
s.public_header_files = 'Classes/**/*.h'
# 库的资源文件,如图片、故事板等
# s.resources = ""
# s.pod_target_xcconfig和s.xcconfigXcode项目的配置信息。
# 库依赖的其他CocoaPods库。
s.dependency 'Flutter'
s.platform = :ios, '12.0'
# 依赖版本: https://github.com/CocoaPods/Specs/tree/master/Specs/a/a/a/GDTMobSDK
s.dependency 'GDTMobSDK','~> 4.15.10'
# s.frameworks和s.libraries库依赖的系统框架和库。
s.static_framework = true
# 库支持的最低iOS版本
# s.watchos.deployment_target、s.tvos.deployment_target等支持的其他平台和版本。
# 广点通的 SDK 最低支持 9.0 所以,这里设置 9.0
s.ios.deployment_target = '9.0'
# Pod 支持的平台和版本。例如s.platform = :ios, '8.0' 表示这个 Pod 支持 iOS 8.0 及更高版本。
# s.platform = :ios, '9.0'
# s.prefix_header_contents前缀头文件的内容。
# s.ios.exclude_files、s.osx.exclude_files等排除的文件和平台。
# 通过这些参数,开发者可以详细描述自己的库,确保其他开发者能够正确地使用和集成该库‌
# s.vendored_frameworks = "Frameworks/*.framework"
# 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