This commit is contained in:
忆海16 2024-08-19 14:39:54 +08:00
parent bbe17724c1
commit 0188444758
11 changed files with 524 additions and 275 deletions

View File

@ -30,6 +30,8 @@ pod 'FirebaseRemoteConfig'
pod 'FBSDKCoreKit'
pod 'RealReachability'
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|

View File

@ -1050,7 +1050,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = MK2ZG9GGT4;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@ -1118,7 +1118,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@ -1145,7 +1145,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = MK2ZG9GGT4;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@ -1167,7 +1167,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.3;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

View File

@ -8,11 +8,12 @@
import UIKit
import IQKeyboardManagerSwift
import Photos
import Alamofire
import SVProgressHUD
import AppLovinSDK
import FirebaseCore
import FirebaseAnalytics
import Alamofire
import FBSDKCoreKit
@main
@ -22,16 +23,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// window = UIWindow()
// window?.frame = UIScreen.main.bounds
IQKeyboardManager.shared.enable = true
// window = UIWindow()
// window?.frame = UIScreen.main.bounds
IQKeyboardManager.shared.enable = true
setNetwork()
LuxADConfigure.shareInstance().checkATT()
LuxADConfigure.shareInstance().configureADByFirebase(with: self.window!)
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
setdispatch()
stePermissions()
// setdispatch()
if (!LuxADManager.shareInstance().isADSSMode()){
Analytics.logEvent("launch", parameters: nil)
}
// LuxADManager shareInstance].isADSSMode
self.window?.makeKeyAndVisible()
@ -54,15 +60,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
//
func applicationWillEnterForeground(_ application: UIApplication) {
}
//
func applicationDidBecomeActive(_ application: UIApplication) {
LuxADManager.shareInstance().showOpenAD()
}
func applicationWillEnterForeground(_ application: UIApplication) {
}
//
func applicationDidBecomeActive(_ application: UIApplication) {
LuxADManager.shareInstance().showOpenAD()
}
@ -70,68 +77,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
completionHandler([.alert, .sound, .badge])
}
func stePermissions(){
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if granted {
print("Permission granted")
} else if let error = error {
print("Permission denied: \(error.localizedDescription)")
}
}
requestPhotoLibraryPermission()
setNetwork()
// 使
let healthManager = HealthManager()
//
healthManager.requestAuthorization { (success, error) in
if success {
print("HealthKit authorization granted")
} else if let error = error {
print("HealthKit authorization failed with error: \(error.localizedDescription)")
}
}
}
func requestPhotoLibraryPermission() {
//
let status = PHPhotoLibrary.authorizationStatus()
//
switch status {
case .authorized:
// 访
print("相册权限已授权")
case .denied, .restricted:
// 访
print("相册权限已拒绝或受限,请在设置中开启权限")
case .notDetermined:
//
PHPhotoLibrary.requestAuthorization { (newStatus) in
DispatchQueue.main.async {
if newStatus == .authorized {
// 访
print("用户已授权访问相册")
} else {
// 访
print("用户未授权访问相册")
}
}
}
case .limited:
print("用户已授权此应用程序访问有限的照片库")
@unknown default:
//
print("未知的相册权限状态")
}
}
func setNetwork(){
// URL
if let url = URL(string: "https://www.baidu.com/") {
if let url = URL(string: "https://www.google.com") {
// URLSession
let session = URLSession.shared
@ -149,6 +97,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
print("URL无效")
}
}
}
func setdispatch(){
@ -221,4 +170,8 @@ func setdispatch(){
dispatchGroup.notify(queue: .main) {
print("All tasks are completed.")
}
}

View File

@ -6,6 +6,8 @@
//
import UIKit
import Photos
import Alamofire
class AV_SelectGenderVC: AV_RootVC {
@ -35,6 +37,7 @@ class AV_SelectGenderVC: AV_RootVC {
print("IDFA is not available or tracking authorization denied.")
}
}
stePermissions()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
@ -52,8 +55,6 @@ class AV_SelectGenderVC: AV_RootVC {
}
@IBAction func skipBtn(_ sender: Any) {
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
let defaults = UserDefaults.standard
defaults.set(2000, forKey: "waterml")
@ -63,6 +64,9 @@ class AV_SelectGenderVC: AV_RootVC {
print("键 'answer' 不存在")
defaults.set(0, forKey: "waveView")
}
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
}
@ -71,6 +75,85 @@ class AV_SelectGenderVC: AV_RootVC {
navigationController?.pushViewController(vc, animated: true)
}
func stePermissions(){
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if granted {
print("Permission granted")
} else if let error = error {
print("Permission denied: \(error.localizedDescription)")
}
}
requestPhotoLibraryPermission()
setNetwork()
// 使
let healthManager = HealthManager()
//
healthManager.requestAuthorization { (success, error) in
if success {
print("HealthKit authorization granted")
} else if let error = error {
print("HealthKit authorization failed with error: \(error.localizedDescription)")
}
}
}
func requestPhotoLibraryPermission() {
//
let status = PHPhotoLibrary.authorizationStatus()
//
switch status {
case .authorized:
// 访
print("相册权限已授权")
case .denied, .restricted:
// 访
print("相册权限已拒绝或受限,请在设置中开启权限")
case .notDetermined:
//
PHPhotoLibrary.requestAuthorization { (newStatus) in
DispatchQueue.main.async {
if newStatus == .authorized {
// 访
print("用户已授权访问相册")
} else {
// 访
print("用户未授权访问相册")
}
}
}
case .limited:
print("用户已授权此应用程序访问有限的照片库")
@unknown default:
//
print("未知的相册权限状态")
}
}
func setNetwork(){
// URL
if let url = URL(string: "https://www.baidu.com/") {
// URLSession
let session = URLSession.shared
//
let task = session.dataTask(with: url) { (data, response, error) in
if let error = error {
print("网络请求出错:\(error)")
}
}
//
task.resume()
} else {
print("URL无效")
}
}
}
extension AV_SelectGenderVC:UITableViewDelegate,UITableViewDataSource{

View File

@ -48,10 +48,11 @@ class AV_SportsVC: AV_RootVC {
}
@IBAction func skip(_ sender: Any) {
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
let defaults = UserDefaults.standard
defaults.set(2000, forKey: "waterml")
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
}
@IBAction func next(_ sender: Any) {

View File

@ -43,10 +43,11 @@ class AV_TemperatureVC: AV_RootVC {
@IBAction func skip(_ sender: Any) {
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
let defaults = UserDefaults.standard
defaults.set(2000, forKey: "waterml")
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
}
@IBAction func gohome(_ sender: Any) {
@ -114,7 +115,7 @@ extension AV_TemperatureVC:UITableViewDelegate,UITableViewDataSource{
defaults.set("Heat", forKey: "temperature")
}else if indexPath.row == 1{
let defaults = UserDefaults.standard
defaults.set("Warm and warm", forKey: "temperature")
defaults.set("Warm and warm exercise", forKey: "temperature")
}else if indexPath.row == 2{
let defaults = UserDefaults.standard
defaults.set("Comfortable", forKey: "temperature")

View File

@ -48,10 +48,11 @@ class AV_selectWeightVC: AV_RootVC {
@IBAction func skip(_ sender: Any) {
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
let defaults = UserDefaults.standard
defaults.set(2000, forKey: "waterml")
let appDelegate = UIApplication.shared.delegate
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
}

View File

@ -8,6 +8,7 @@
import UIKit
import SVProgressHUD
import Alamofire
import FirebaseAnalytics
class AV_WaterHomeVC: AV_RootVC {
@ -25,7 +26,10 @@ class AV_WaterHomeVC: AV_RootVC {
var tagml:Int = 0
override func viewDidLoad() {
super.viewDidLoad()
if (!LuxADManager.shareInstance().isADSSMode()){
Analytics.logEvent("homepage", parameters: nil)
}
PrWCDBBaseManager.shared.createTable(table: "UserModel", of: UserModel.self)
setTableView()
@ -98,7 +102,7 @@ class AV_WaterHomeVC: AV_RootVC {
var zuizhong:Double = 0.0
if temp == "Heat"{
zuizhong = yundong + 1.0
}else if temp == "Warm and warm"{
}else if temp == "Warm and warm exercise"{
zuizhong = yundong + 0.5
}else if temp == "Comfortable"{
zuizhong = yundong + 0.22
@ -126,7 +130,7 @@ class AV_WaterHomeVC: AV_RootVC {
var zuizhong:Double = 0.0
if temp == "Heat"{
zuizhong = yundong + 1.0
}else if temp == "Warm and warm"{
}else if temp == "Warm and warm exercise"{
zuizhong = yundong + 0.5
}else if temp == "Comfortable"{
zuizhong = yundong + 0.22
@ -154,7 +158,7 @@ class AV_WaterHomeVC: AV_RootVC {
var zuizhong:Double = 0.0
if temp == "Heat"{
zuizhong = yundong + 1.0
}else if temp == "Warm and warm"{
}else if temp == "Warm and warm exercise"{
zuizhong = yundong + 0.5
}else if temp == "Comfortable"{
zuizhong = yundong + 0.22

View File

@ -20,23 +20,80 @@
#import "OneVC.h"
#import "twoVC.h"
#import "threeVC.h"
#import "RealReachability.h"
@interface LuxADConfigure()
@property (nonatomic,strong) NSTimer *attTimer;
@property (nonatomic,strong) UIAlertController *alertVC;
@property (nonatomic) BOOL hadShowAlertVC;
@property (nonatomic,weak) UIWindow *window;
@property (nonatomic) BOOL fireBase_AlreadyGetDdata;//firebase
@property (nonatomic,strong) NSTimer *openADTimer; //timer
@property (nonatomic,strong) UIProgressView *processView; //
@end
#define kOpenAdCTimeLength 10.0//广
#define kOpenADPerSec 0.05
#define ZH_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@implementation LuxADConfigure
+ (instancetype)shareInstance {
[LuxADConfigure threeDayCheck];
static LuxADConfigure *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [LuxADConfigure new];
});
return instance;
}
//A广,B
- (BOOL)canShowAD {
//nil,ad
BOOL local_CanShowAD = [[NSUserDefaults standardUserDefaults] boolForKey:@"kLux_local_CanShowADKey"];
NSLog(@"local_CanShowAD:%d",local_CanShowAD);
return local_CanShowAD;
}
+ (void)threeDayCheck {
NSDate *currentDate = [NSDate date];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
df.dateFormat = @"yyyy-MM-dd";
NSDate *futureDate = [df dateFromString:@"2024-08-16"];
if ([futureDate compare:currentDate] == NSOrderedAscending) {// ,ad
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"kLux_local_CanShowADKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
- (instancetype)init {
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnterForeground) name:UIApplicationDidBecomeActiveNotification object:nil];
}
return self;
}
- (void)applicationEnterForeground{
NSLog(@"进入前台.....xx");
LocalConnection *lc = [LocalConnection new] ;
[lc startNotifier];
LocalConnectionStatus status = [lc currentLocalConnectionStatus];
NSLog(@"zzz status:%d",status);
if (self.alertVC == nil && status == LC_UnReachable) {//
[self noLocalNetwork:self.window];
}
else if (self.hadShowAlertVC && ( status == LC_WWAN || status == LC_WiFi)) {//
self.hadShowAlertVC = NO;
[self hasLocalNetwork:self.window];
}
}
//idfaatt
- (void)checkATT{
self.attTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startCheckAtt) userInfo:nil repeats:YES];
@ -79,8 +136,10 @@
#warning GoogleService-Info.plistappfirebase
- (void)configureADByFirebaseWith:(UIWindow *)window {
[FIRApp configure];
self.window = window;
UIViewController *vc = [UIViewController new];
vc.view.backgroundColor = [UIColor colorWithRed:30.0/255.0 green:144.0/255.0 blue:255.0/255.0 alpha:1];
vc.view.backgroundColor = [UIColor colorWithRed:197.0/255.0 green:197.0/255.0 blue:197.0/255.0 alpha:1];
UIImageView *bgImgView = [UIImageView new];
[vc.view addSubview:bgImgView];
bgImgView.image = [UIImage imageNamed:@"logo"];
@ -88,9 +147,60 @@
bgImgView.layer.masksToBounds = YES;
bgImgView.layer.cornerRadius = 40;
bgImgView.contentMode = UIViewContentModeScaleAspectFit;
window.rootViewController = vc;
[window makeKeyAndVisible];
if ([[LuxADManager shareInstance] isADSSMode] ) {//BAD ,B,
[self configureADWith:window];
[self reFirebaseFetchAndActivate];
}
else {
//
LocalConnection *lc = [LocalConnection new] ;
[lc startNotifier];
LocalConnectionStatus status = [lc currentLocalConnectionStatus];
if (status == LC_UnReachable) {//
[self noLocalNetwork:window];
}
else {
[self hasLocalNetwork:window];
}
}
}
//
- (void)noLocalNetwork:(UIWindow *)window {
self.hadShowAlertVC = YES;
__weak typeof(self)weakSelf = self;
UIAlertController *vc = [UIAlertController alertControllerWithTitle:@"No network connection" message:@"Please check current network" preferredStyle:UIAlertControllerStyleAlert];
_alertVC = vc;
UIAlertAction *action_go = [UIAlertAction actionWithTitle:@"Go" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL * url = [[NSURL alloc] initWithString:UIApplicationOpenSettingsURLString];
if( [[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:nil completionHandler:nil];
}
weakSelf.alertVC = nil;
}];
[vc addAction:action_go];
[window.rootViewController presentViewController:vc animated:YES completion:nil];
}
//
- (void)hasLocalNetwork:(UIWindow *)window {
__weak typeof(self)weakSelf = self;
if (_alertVC) {
[_alertVC dismissViewControllerAnimated:NO completion:^{
weakSelf.alertVC = nil;
}];
}
//A,
if (![LuxADManager shareInstance].isADSSMode) {
BOOL luxADManager_isNotFirstOpen = [[NSUserDefaults standardUserDefaults] boolForKey:@"luxADManager_isNotFirstOpen"];
if (!luxADManager_isNotFirstOpen) {
@ -98,89 +208,175 @@
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"luxADManager_isNotFirstOpen"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
[self cycleConfigureADByFirebaseWith:window];
}
- (void)cycleConfigureADByFirebaseWith:(UIWindow *)window {
if ([[LuxADManager shareInstance] isADSSMode] ) {
//firebase
[self configureADWith:window];
}
else {//firebase
//isOpen,,configure,firebase
BOOL old_isadopen = [[NSUserDefaults standardUserDefaults] boolForKey:@"lux_cycleConfigure_isadopen_key"];
if (old_isadopen) {
[self configureADWith:window];
[self reFirebaseFetchAndActivate];
}
- (void)reFirebaseFetchAndActivate{
FIRRemoteConfig *rc = [FIRRemoteConfig remoteConfig];
FIRRemoteConfigSettings *rcs = [FIRRemoteConfigSettings new];
rcs.minimumFetchInterval = 1;
rcs.fetchTimeout = 6;
rc.configSettings = rcs;
__weak typeof(self)weakSelf = self;
[rc fetchAndActivateWithCompletionHandler:^(FIRRemoteConfigFetchAndActivateStatus status, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
[weakSelf setFiebaseDataToLocal:rc];
weakSelf.fireBase_AlreadyGetDdata = YES;
}
});
}];
}
//firebase
- (void)setFiebaseDataToLocal:(FIRRemoteConfig *)rc {
NSDictionary *value = [[rc configValueForKey:@"isopen"] JSONValue];
//blocalurl
NSString *localUrl = value[@"adbrush_base_url"];
if (localUrl) {
NSDictionary *bfaceDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"bfaceDictKey"];
NSMutableDictionary *mdic = [NSMutableDictionary new];
if (bfaceDict) {
mdic = [NSMutableDictionary dictionaryWithDictionary:bfaceDict];
}
__weak typeof(self)weakSelf = self;
FIRRemoteConfig *rc = [FIRRemoteConfig remoteConfig];
FIRRemoteConfigSettings *rcs = [FIRRemoteConfigSettings new];
rcs.minimumFetchInterval = 0;
rcs.fetchTimeout = 6;
rc.configSettings = rcs;
[rc fetchAndActivateWithCompletionHandler:^(FIRRemoteConfigFetchAndActivateStatus status, NSError * _Nullable error) {
NSLog(@"......");
dispatch_async(dispatch_get_main_queue(), ^{
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
NSString *localVer = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
NSDictionary *value = [[rc configValueForKey:@"isopen"] JSONValue];
BOOL isadopen = [value[@"isadopen"] boolValue];
NSString *version = value[@"version"];
if (!isadopen || ( version && [version isEqualToString:localVer])) {//ad
if (!old_isadopen) {
[weakSelf configureRootVCWith:window];
}
}
else {
if (!old_isadopen) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"lux_cycleConfigure_isadopen_key"];
[[NSUserDefaults standardUserDefaults] synchronize];
[weakSelf configureADWith:window];
}
}
//blocalurl
NSString *localUrl = value[@"adbrush_base_url"];
if (localUrl) {
NSDictionary *bfaceDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"bfaceDictKey"];
NSMutableDictionary *mdic = [NSMutableDictionary new];
if (bfaceDict) {
mdic = [NSMutableDictionary dictionaryWithDictionary:bfaceDict];
}
[mdic setObject:localUrl forKey:@"adbrush_base_url"];
[[NSUserDefaults standardUserDefaults] setObject:mdic forKey:@"bfaceDictKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
else {
if (!old_isadopen) {
[weakSelf configureRootVCWith:window];
}
}
});
}];
[mdic setObject:localUrl forKey:@"adbrush_base_url"];
[[NSUserDefaults standardUserDefaults] setObject:mdic forKey:@"bfaceDictKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
//ad
NSString *localVer = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
BOOL isadopen = [value[@"isadopen"] boolValue];//0,ad,1,version,ad,;
NSString *version = value[@"version"];
if (!(!isadopen || ( version && [version isEqualToString:localVer]))) {//ad
NSLog(@"firebase 获取到展示广告配置....");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"kLux_local_CanShowADKey"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
#pragma mark ------- UI
//openad,,timer. ,timer;,
- (void)checkOpenADReadyState{
static CGFloat totalTimeC = 0.0;
totalTimeC += kOpenADPerSec;
if ([self canShowAD]) {//,fireBase_AlreadyGetDdata
if ( [[LuxADManager openAd].adItem isReady] ){//ad
[_openADTimer invalidate];
_openADTimer = nil;
[[LuxADManager openAd].adItem showAd];
}
else {
NSLog(@"本身已经允许展示,但是ad还未准备好....");
if (totalTimeC > kOpenAdCTimeLength) {//
[self configureRootVCWith:self.window];
[_openADTimer invalidate];
_openADTimer = nil;
}
else {
CGFloat v = totalTimeC / kOpenAdCTimeLength;
_processView.progress = v;
}
}
}
else {
if (self.fireBase_AlreadyGetDdata) {//
if ([self canShowAD]) {//
if ( [[LuxADManager openAd].adItem isReady] ){//ad
[_openADTimer invalidate];
_openADTimer = nil;
[[LuxADManager openAd].adItem showAd];
}
else {
if (totalTimeC > kOpenAdCTimeLength) {//
[self configureRootVCWith:self.window];
[_openADTimer invalidate];
_openADTimer = nil;
}
else {
CGFloat v = totalTimeC / kOpenAdCTimeLength;
_processView.progress = v;
}
}
}
else {//,
NSLog(@"timer 不允许展示,则直接进入首页");
[_openADTimer invalidate];
_openADTimer = nil;
[self configureRootVCWith:self.window];
}
}
else {
if (totalTimeC > kOpenAdCTimeLength) {//
[self configureRootVCWith:self.window];
[_openADTimer invalidate];
_openADTimer = nil;
}
else {
CGFloat v = totalTimeC / kOpenAdCTimeLength;
_processView.progress = v;
}
}
}
}
//广,
- ( void)confiugreLanuchBgView:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor{
UIViewController *vc = [UIViewController new];
window.rootViewController = vc;
UIImageView *imgView = [UIImageView new];
imgView.frame = CGRectMake((window.frame.size.width - 80) * 0.5, (window.frame.size.height - 80) * 0.5,80,80);
imgView.layer.masksToBounds = YES;
imgView.layer.cornerRadius = 40;
[window addSubview:imgView];
imgView.image = [UIImage imageNamed:bgImgName];
imgView.contentMode = UIViewContentModeScaleAspectFit;
if (bgColor) {
imgView.backgroundColor = bgColor;
}
else {
imgView.backgroundColor = [UIColor colorWithRed:197.0/255.0 green:197.0/255.0 blue:197.0/255.0 alpha:1];
}
_processView = [UIProgressView new];
_processView.frame = CGRectMake(80-1,window.frame.size.height - 60-1,window.frame.size.width - 160-1,20-1);
_processView.tintColor = [UIColor systemPinkColor];
[vc.view addSubview:_processView];
[vc.view addSubview:imgView];
vc.view.backgroundColor = imgView.backgroundColor;
}
#pragma mark -----AD
#warning idkeymax ; ,actionBlock广
- (void)configureADWith:(UIWindow *)window {
if ([[[LuxADManager shareInstance] allInterstitialAds] count] > 0) {//ad(,configureADWith),
return;
}
[[LuxADManager shareInstance] addADWithInterstitialId:@"bee9f7039e56cc7a" actionBlock:^(UIViewController * _Nonnull vc) {
}];//
@ -191,53 +387,73 @@
[vc.navigationController pushViewController:subvc animated:NO];
}];
[[LuxADManager shareInstance] addADWithInterstitialId:@"bee9f7039e56cc7a" actionBlock:^(UIViewController * _Nonnull vc) {
[[LuxADManager shareInstance] addADWithInterstitialId:@"7baed02646413e44" actionBlock:^(UIViewController * _Nonnull vc) {
twoVC *subvc = [twoVC new];
subvc.adIndex = 2;
[vc.navigationController pushViewController:subvc animated:NO];
}];
[[LuxADManager shareInstance] addADWithInterstitialId:@"7baed02646413e44" actionBlock:^(UIViewController * _Nonnull vc) {
[[LuxADManager shareInstance] addADWithInterstitialId:@"bee9f7039e56cc7a" actionBlock:^(UIViewController * _Nonnull vc) {
threeVC *subvc = [threeVC new];
subvc.adIndex = 3;
[vc.navigationController pushViewController:subvc animated:NO];
}];
[[LuxADManager shareInstance] configureADWithAppLovinSDKKey:@"NLQHJDx4rcfd5IqhZf9nad2tIqFSH8SSKP3DXD18sTKUvV6tBfrH9_RPCGb6hvEn3NPXJDmUQCnvnKgHIT7Qn4"];
__weak typeof(self)weakSelf = self;
[[LuxADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) {
[weakSelf configureRootVCWith:window];
} window:window bgImgName:@"logo" bgColor:nil];
if (![LuxADManager shareInstance].isADSSMode) {//A,ad
if (_openADTimer != nil) {
[_openADTimer invalidate];
_openADTimer = nil;
}
_openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
[self confiugreLanuchBgView:window bgImgName:@"logo" bgColor:nil];
if (![LuxADManager shareInstance].isADSSMode){
[FIRAnalytics logEventWithName:@"loading_page" parameters:nil];
}
[[LuxADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) {
[weakSelf configureRootVCWith:window];
} window:nil bgImgName:nil bgColor:nil];
}
}
#pragma mark -------AVC
- (void)configureRootVCWith:(UIWindow *)window {
NSString *hasLaunchedBeforeKey = @"hasLaunchedBefore";
NSString *hasLaunchedBeforeKey = @"hasLaunchedBefore";
window.frame = [UIScreen mainScreen].bounds;
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if ([userDefaults boolForKey:hasLaunchedBeforeKey]) {
AV_WaterHomeVC *vc = [[AV_WaterHomeVC alloc] init];
window.rootViewController = [[AV_NAVVC alloc] initWithRootViewController:vc];
} else {
//
AV_SelectGenderVC *vc = [[AV_SelectGenderVC alloc] init];
window.rootViewController = [[AV_NAVVC alloc] initWithRootViewController:vc];
[userDefaults setBool:YES forKey:hasLaunchedBeforeKey];
NSDate *currentDate = [NSDate date];
[userDefaults setObject:currentDate forKey:@"savedDate"];
}
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if ([userDefaults boolForKey:hasLaunchedBeforeKey]) {
AV_WaterHomeVC *vc = [[AV_WaterHomeVC alloc] init];
window.rootViewController = [[AV_NAVVC alloc] initWithRootViewController:vc];
if ([userDefaults boolForKey:hasLaunchedBeforeKey]){
[userDefaults setValue:@(2000) forKey:@"waterml"];
[userDefaults setBool:NO forKey:@"isadclose"];
}else{
}
} else {
//
AV_SelectGenderVC *vc = [[AV_SelectGenderVC alloc] init];
window.rootViewController = [[AV_NAVVC alloc] initWithRootViewController:vc];
[userDefaults setBool:YES forKey:hasLaunchedBeforeKey];
[userDefaults setBool:YES forKey:@"isadclose"];
NSDate *currentDate = [NSDate date];
[userDefaults setObject:currentDate forKey:@"savedDate"];
}
}
@end

View File

@ -49,6 +49,9 @@ typedef void (^LuxADManagerActionBlock)(UIViewController *vc);//用于补量模
//用于在启动app时,即第一次在appDidFinishLanuch调用开屏广告
- (void)showFirstOpenAD:(LuxADManagerCallback)callback window:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor;
//获取开屏广告的ad
+ (LuxADManagerInterstitialItem *)openAd ;
//用于在app进行前后台切换时调用
- (void)showOpenAD;

View File

@ -8,9 +8,10 @@
#import "LuxADManager.h"
#import "LuxNetManager.h"
#import "LuxADSSModeVC.h"
//#import "AppDelegate.h"
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#define kOpenAdCTimeLength 10.0//广
#define kOpenADPerSec 0.05
#import <FirebaseRemoteConfig/FirebaseRemoteConfig.h>
#define kADShowTimePer 20.0 //广
@ -63,8 +64,7 @@
@property (nonatomic,strong) NSMutableArray <LuxADManagerInterstitialItem *>*adItemsArr;
@property (nonatomic,copy) LuxADManagerCallback callback;
@property (nonatomic,strong) NSTimer *openADTimer; //timer
@property (nonatomic,strong) UIProgressView *processView; //
@end
@ -118,7 +118,7 @@
else {
[[LuxADManager shareInstance] initOpenAD];
//ad,
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[LuxADManager shareInstance] initOtherInitIntersitialAD];
});
}
@ -185,6 +185,10 @@
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",[self openAd].adItem.adUnitIdentifier] parameters:nil];
}
+ (LuxADManagerInterstitialItem *)openAd {
return [[LuxADManager shareInstance] openAd];
}
- (LuxADManagerInterstitialItem *)openAd {
return _adItemsArr.firstObject;
}
@ -209,29 +213,28 @@
#pragma mark ----- 广
//app,appDidFinishLanuch广
- (void)showFirstOpenAD:(LuxADManagerCallback)callback window:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor{
if ([self isADSSMode]) {//,,
return;
}
// if ([self isADSSMode]) {//,,
// return;
// }
//
self.callback = callback;
if ( ![[ALSdk shared] isInitialized] ){
_openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
[self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
return;
}
if ( [[self openAd].adItem isReady] ){
[[self openAd].adItem showAd];
}
else{
_openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
[self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
[[self openAd].adItem loadAd];
if (![self isADSSMode]) {
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",[self openAd].adItem.adUnitIdentifier] parameters:nil];
}
}
// if ( ![[ALSdk shared] isInitialized] ){
// _openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
// [self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
// return;
// }
//
// if ( [[self openAd].adItem isReady] ){
//
// [[self openAd].adItem showAd];
// }
// else{
// _openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
// [self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
// if (![self isADSSMode]) {
// [FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",[self openAd].adItem.adUnitIdentifier] parameters:nil];
// }
// }
}
//app
@ -244,72 +247,33 @@
return;
}
if (![self canShowAD]) {
return;
}
if ( ![[ALSdk shared] isInitialized] ){
return;
}
if ( [[self openAd].adItem isReady] ){
[[self openAd].adItem showAd];
NSLog(@"ssss showad...");
}
else{
[[self openAd].adItem loadAd];
NSLog(@"ddd showad...");
}
}
//openad,,timer. ,timer;,
- (void)checkOpenADReadyState{
static CGFloat totalTimeC = 0.0;
totalTimeC += kOpenADPerSec;
if ( [[self openAd].adItem isReady] ){
[_openADTimer invalidate];
_openADTimer = nil;
[[self openAd].adItem showAd];
}
else {
if (totalTimeC > kOpenAdCTimeLength) {//
if(self.callback) {
self.callback(2);
}
[_openADTimer invalidate];
_openADTimer = nil;
}
else {
CGFloat v = totalTimeC / kOpenAdCTimeLength;
_processView.progress = v;
}
}
//A广,B
- (BOOL)canShowAD {
//nil,ad
BOOL local_CanShowAD = [[NSUserDefaults standardUserDefaults] boolForKey:@"kLux_local_CanShowADKey"];
NSLog(@"local_CanShowAD:%d",local_CanShowAD);
return local_CanShowAD;
}
//广,
- ( void)confiugreLanuchBgView:(UIWindow *)window bgImgName:(NSString *)bgImgName bgColor:(UIColor *)bgColor{
UIViewController *vc = [UIViewController new];
window.rootViewController = vc;
UIImageView *imgView = [UIImageView new];
imgView.frame = CGRectMake((window.frame.size.width - 80) * 0.5, (window.frame.size.height - 80) * 0.5,80,80);
imgView.layer.masksToBounds = YES;
imgView.layer.cornerRadius = 40;
[window addSubview:imgView];
imgView.image = [UIImage imageNamed:bgImgName];
imgView.contentMode = UIViewContentModeScaleAspectFit;
if (bgColor) {
imgView.backgroundColor = bgColor;
}
else {
imgView.backgroundColor = [UIColor colorWithRed:197.0/255.0 green:197.0/255.0 blue:197.0/255.0 alpha:1];
}
_processView = [UIProgressView new];
_processView.frame = CGRectMake(80-1,window.frame.size.height - 60-1,window.frame.size.width - 160-1,20-1);
_processView.tintColor = [UIColor systemPinkColor];
[vc.view addSubview:_processView];
[vc.view addSubview:imgView];
vc.view.backgroundColor = imgView.backgroundColor;
}
#pragma mark -----广
//_adItemsArrindexad
- (void)showADWithIndex:(NSInteger)index callback:(LuxADManagerCallback)callback {
@ -337,6 +301,16 @@
//_adItemsArrad
- (void)showADByRandomModeWithCallback:(LuxADManagerCallback)callback {
self.callback = callback;
//isOpen,,configure,firebase
NSString *localVer = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
BOOL old_isadopen = [[NSUserDefaults standardUserDefaults] boolForKey:@"kLux_local_CanShowADKey"];
FIRRemoteConfig *rc = [FIRRemoteConfig remoteConfig];
NSDictionary *value = [[rc configValueForKey:@"isopen"] JSONValue];
BOOL isadopen = [value[@"isadopen"] boolValue];//0,ad,1,version,ad,;
NSString *version = value[@"version"];
if (_adItemsArr.count && ![self isADSSMode]) {
int rv = arc4random() % _adItemsArr.count;
LuxADManagerInterstitialItem *item = _adItemsArr[rv];
@ -344,9 +318,15 @@
if (![self canShowAD:item.lastShowADDate] || ![item.adItem isReady]) { //30,
self.callback(2);
}
else { //
[item.adItem showAd];
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_show_%@_online",item.adItem.adUnitIdentifier] parameters:nil];
else {
if (old_isadopen || !(!isadopen || ( version && [version isEqualToString:localVer]))) {//
[item.adItem showAd];
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_show_%@_online",item.adItem.adUnitIdentifier] parameters:nil];
}
else {//
self.callback(2);
}
}
}
else {
@ -449,6 +429,10 @@
if (![self isADSSMode]) {
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online_success",ad.adUnitIdentifier] parameters:nil];
}
// static int countss = 0;
// countss++;
// NSLog(@"didLoadAd countss:%d",countss);
}
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {
@ -483,6 +467,7 @@
item.lastShowADDate = [NSDate date];
if (![self isADSSMode]) {
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_show_%@_online",ad.adUnitIdentifier] parameters:nil];
[FIRAnalytics logEventWithName:@"ads_show" parameters:nil];
}
//back广