Commit f1f7e702 authored by shenyong's avatar shenyong

2.2.4线上版本

parent e920cc85
......@@ -830,7 +830,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.3;
MARKETING_VERSION = 2.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.app.phonemanager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -878,7 +878,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2.3;
MARKETING_VERSION = 2.2.4;
PRODUCT_BUNDLE_IDENTIFIER = com.app.phonemanager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
......
......@@ -14,6 +14,7 @@ import FBAudienceNetwork
import SVProgressHUD
import IronSource
import UnityAds
import FirebaseAnalytics
class ADManager : NSObject, FullScreenContentDelegate {
......@@ -55,8 +56,8 @@ class ADManager : NSObject, FullScreenContentDelegate {
/// 记录插屏上次展示广告的时间
private var interstitiallastAdShowTime: Date?
private var currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "2.2.3"
var onlineVersion = "2.2.3"
private var currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "2.2.4"
var onlineVersion = "2.2.4"
/// 默认每日免费删除次数
......@@ -157,6 +158,9 @@ class ADManager : NSObject, FullScreenContentDelegate {
pram["precision"] = "\(precision.rawValue)"
print("广告价值和来源", pram)
AdRevenueTracker().onPaidEvent(adValue: value)
// 使用 APIReportManager 上报广告价值
APIReportManager().startReport(type: .ad_price, ext: pram)
......@@ -216,6 +220,7 @@ class ADManager : NSObject, FullScreenContentDelegate {
print("广告价值和来源", pram)
// 使用 APIReportManager 上报广告价值
AdRevenueTracker().onPaidEvent(adValue: value)
APIReportManager().startReport(type: .ad_price, ext: pram)
}
......@@ -634,7 +639,7 @@ extension ADManager{
}
func dealVersionShowAD() -> Bool {
let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "2.2.3"
let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "2.2.4"
// 将版本号按点号分割成数组
let currentComponents = currentVersion.components(separatedBy: ".")
......
//
// AdRevenueTracker.swift
// PhoneManager
//
// Created by edy on 2025/6/18.
//
import Foundation
import Foundation
import FirebaseAnalytics
import GoogleMobileAds
import StoreKit
class AdRevenueTracker {
private let taichiPref = UserDefaults.standard
func onPaidEvent(adValue: AdValue) {
// 记录广告收入事件
var params = [String: Any]()
let currentImpressionRevenue = adValue.value.floatValue
params[AnalyticsParameterValue] = currentImpressionRevenue
params[AnalyticsParameterCurrency] = "USD"
// 记录精度类型
let precisionType: String
switch adValue.precision.rawValue {
case 0: precisionType = "UNKNOWN"
case 1: precisionType = "ESTIMATED"
case 2: precisionType = "PUBLISHER_PROVIDED"
case 3: precisionType = "PRECISE"
default: precisionType = "Invalid"
}
params["precisionType"] = precisionType
// 记录广告收入事件
Analytics.logEvent("Ad_Impression_Revenue", parameters: params)
// 获取并更新本地累计值
let previousTaichiTroasCache = taichiPref.float(forKey: "TaichiTroasCache")
let currentTaichiTroasCache = previousTaichiTroasCache + currentImpressionRevenue
// 检查是否需要发送tROAS事件
if currentTaichiTroasCache >= 0.01 {
// 发送tROAS事件并重置缓存
var roasbundle = [String: Any]()
roasbundle[AnalyticsParameterValue] = Double(currentTaichiTroasCache)
roasbundle[AnalyticsParameterCurrency] = "USD"
Analytics.logEvent("Total_Ads_Revenue_001", parameters: roasbundle)
Analytics.logEvent("hybrid_revenue", parameters: roasbundle)
taichiPref.set(0.0, forKey: "TaichiTroasCache")
} else {
// 继续累积收入
taichiPref.set(currentTaichiTroasCache, forKey: "TaichiTroasCache")
}
// 同步保存设置(Swift的UserDefaults自动异步保存,无需显式调用)
taichiPref.synchronize() // 注意:iOS 12+后通常不需要调用此方法
}
// 上报数据
func purchasingSuccessReport(type:SubscriptionType){
guard let prod = IAPManager.share.getSKProductBy(type) else{
return
}
// prod.localizedPrice
let pram = [
AnalyticsParameterValue:prod.price.floatValue,
AnalyticsParameterCurrency:prod.priceLocale.currencyCode ?? "USD"
] as [String : Any]
Analytics.logEvent("hybrid_revenue", parameters: pram)
}
}
......@@ -129,6 +129,19 @@ class IAPManager: NSObject {
deinit {
SKPaymentQueue.default().remove(self)
}
func getSKProductBy(_ type:SubscriptionType) ->SKProduct?{
switch type {
case .none:
return nil
case .week:
return weekProduct
case .year:
return yearProduct
case .lifetime:
return lifetimeProduct
}
}
}
// MARK: - Public Methods
......@@ -304,8 +317,10 @@ private extension IAPManager {
case .success(let receipt):
let status = self.checkSubscriptionStatus(receiptInfo: receipt)
self.isSubscribed = status.isActive
if status.isActive {
if transaction.transactionState == .purchased {
AdRevenueTracker().purchasingSuccessReport(type: status.subscriptionType)
self.purchaseCompletion?(.success(true))
} else {
self.restoreCompletion?(.success(true))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment