novvy_ads 1.0.0-beta.44
novvy_ads: ^1.0.0-beta.44 copied to clipboard
Flutter plugin for Novvy Ads SDK.
1.0.0-beta.44 #
升级注意:本版本包含破坏性变更,直接升级会导致编译报错,请按下方迁移指南操作。
破坏性变更(必须修改,否则编译报错) #
1. 用户信息与内容上下文分离设置
原来的 updateContext(NovvyContextConfig) 已移除。需拆分为两类调用:
用户画像(用户登录/登出/付费状态变化时设置,全局生效):
// 用户登录后 — 一次性写入完整画像
NovvyAds.setUserProfile(NovvyUserProfile(
userId: user.id,
hashedEmail: NovvyAds.hashEmail(user.email),
isPaidUser: user.isPremium,
age: user.age,
));
// 用户付费升级 — 只更新单个字段,其他字段保持不变
NovvyAds.updateUserProfile(NovvyUserProfile(isPaidUser: true));
// 用户登出 — 传空对象清除所有用户字段
NovvyAds.setUserProfile(NovvyUserProfile());
内容上下文(进入播放页、换集时设置):
NovvyAds.setContentContext(NovvyContentContext(
seriesName: episode.seriesName,
episodeNumber: episode.number,
contentUrl: episode.url,
));
setUserProfile与updateUserProfile的区别:前者 null 字段清除原有值(全量覆盖),后者 null 字段保留原有值(增量合并)。用户登出用setUserProfile(NovvyUserProfile());仅更新付费状态用updateUserProfile(NovvyUserProfile(isPaidUser: true))。
2. NovvyContextConfig 类已移除
不再有 NovvyContextConfig,替换为 NovvyUserProfile(用户字段)和 NovvyContentContext(内容字段)。
3. NovvyAdsLegacy 已移除
若仍在使用 NovvyAdsLegacy.initialize() 或 NovvyAdsLegacy.setContext(),请改用 NovvyAds。
iOS 接入配置变更(首次接入必看) #
1. Podfile 链接模式调整(必改,否则 pod install 报错)
本版本起,插件传递依赖 Google-Mobile-Ads-SDK ~> 12.0,该 SDK 以静态二进制发布。默认的 use_frameworks!(动态)与静态二进制传递依赖不兼容,pod install 会报 transitive dependencies that include statically linked binaries 并失败。
需在 ios/Podfile 中将链接模式切换为 :static:
target 'Runner' do
use_frameworks! :linkage => :static # ← 原来是 use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
2. Info.plist 必填字段
iOS 现在需要在 Info.plist 中额外声明 AdMob App ID,缺少此项会导致 App 启动时直接崩溃:
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
详见 README 中"iOS Setup"章节。
依赖变更 #
Google-Mobile-Ads-SDK ~> 12.0成为插件的传递依赖(驱动内置的 AdMob mediation 适配器)。- 若项目已使用
google_mobile_ads: ^7.0.0(绑 GMA 12.x),无需调整。 - 若仍在使用
google_mobile_ads: ^5.x/^6.x(绑 GMA 11.x 或更早),pod install会报could not find compatible versions—— 需升级到google_mobile_ads: ^7.0.0。
- 若项目已使用
- AdMob mediation 适配器现已内置,无需在 Podfile 中额外声明
pod 'NovvyAds/AdMob'(旧 README 的写法已过时,加了会和插件内置版本冲突)。仅需在 AdMob 控制台为每个广告单元注册NovvyAdMobMediationAdapter作为 Custom Event 即可启用。 - 底层 NovvyAds iOS SDK 从 1.0.0-beta.10 升级至 1.0.0-beta.14(含若干稳定性修复,对宿主 App 无 API 变化)。
行为变更(不需要修改代码,但应了解) #
initialize()可重复调用:每次调用都会替换 callback 并重新触发服务端初始化请求;若有并发调用,以最后一次的响应为准。适用于登录/登出后需要刷新服务端配置的场景。- 展示失败时会收到失败回调:此前若广告加载完成后展示时恰好没有可用的 Activity(Android)或 ViewController(iOS)(如屏幕旋转期间),会静默失败、宿主收不到任何通知。现在会触发
onInterstitialFailed/onRewardedFailed。