diff --git a/src/Environment/iOS/iOSDetail.h b/src/Environment/iOS/iOSDetail.h index dd44259014..96e36acb4a 100644 --- a/src/Environment/iOS/iOSDetail.h +++ b/src/Environment/iOS/iOSDetail.h @@ -15,6 +15,7 @@ + (NSString *)getDeviceId; + (NSString *)getDeviceName; ++ (BOOL)isAppTrackingTransparencyAllowed; + (NSString *)getIDFA; + (BOOL)isValidIDFA; diff --git a/src/Environment/iOS/iOSDetail.mm b/src/Environment/iOS/iOSDetail.mm index 93440a3f36..890d0b28a5 100644 --- a/src/Environment/iOS/iOSDetail.mm +++ b/src/Environment/iOS/iOSDetail.mm @@ -18,6 +18,20 @@ + (NSString *)getDeviceName { return deviceName; } ++ (BOOL)isAppTrackingTransparencyAllowed { + if (@available(iOS 14.5, *)) { + if (ATTrackingManager.trackingAuthorizationStatus == ATTrackingManagerAuthorizationStatusAuthorized) { + return YES; + } + } else { + if ([iOSDetail isValidIDFA] == YES) { + return YES; + } + } + + return NO; +} + + (NSString *)getIDFA { NSUUID * idfa_uuid = [iOSDetail getAdIdentifier]; @@ -50,29 +64,29 @@ + (BOOL)isValidIDFA { } + (UIWindow *)getRootWindow { - UIApplication *application = [UIApplication sharedApplication]; + UIApplication * application = [UIApplication sharedApplication]; id delegate = application.delegate; - UIWindow *window = delegate.window; + UIWindow * window = delegate.window; return window; } + (UIView *)getRootView { - UIWindow *window = [iOSDetail getRootWindow]; - UIView *view = [window.subviews objectAtIndex:0]; + UIWindow * window = [iOSDetail getRootWindow]; + UIView * view = [window.subviews objectAtIndex:0]; return view; } + (UIViewController *)getRootViewController { - UIWindow *window = [iOSDetail getRootWindow]; + UIWindow * window = [iOSDetail getRootWindow]; UIViewController *viewController = window.rootViewController; return viewController; } + (NSUUID *)getAdIdentifier { - NSUUID *idfa_uuid = [[ASIdentifierManager sharedManager] advertisingIdentifier]; + NSUUID * idfa_uuid = [[ASIdentifierManager sharedManager] advertisingIdentifier]; return idfa_uuid; } @@ -136,7 +150,7 @@ + (void)adRevenue:(iOSAdRevenueParam *)revenue { + (void)transparencyConsent:(iOSTransparencyConsentParam *)consent { [iOSDetail addMainQueueOperation:^{ - NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; + NSObject * delegate = [iOSDetail getUIMainApplicationDelegate]; [delegate eventTransparencyConsent:consent]; }]; @@ -151,7 +165,7 @@ + (void)log:(iOSLogRecordParam *)record { } + (NSString *)pathForTemporaryFileWithPrefix:(NSString *)prefix ext:(NSString *)ext { - NSString *result; + NSString * result; CFUUIDRef uuid = CFUUIDCreate(NULL); CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid); @@ -180,8 +194,8 @@ + (void)showOkAlertWithViewController:(UIViewController *)viewController return; } - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + UIAlertController * alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction * okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { Mengine::Helper::dispatchMainThreadEvent([ok]() { ok(); }); @@ -218,11 +232,11 @@ + (void)showAreYouSureAlertDialogWithContext:(UIViewController *)viewController NSString * areYouSureText = @"\n\nAre you sure?"; NSString * fullMessage = [message stringByAppendingString:areYouSureText]; - UIAlertController *alert = [UIAlertController alertControllerWithTitle:title + UIAlertController * alert = [UIAlertController alertControllerWithTitle:title message:fullMessage preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" + UIAlertAction * yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { Mengine::Helper::dispatchMainThreadEvent([yes]() { @@ -230,7 +244,7 @@ + (void)showAreYouSureAlertDialogWithContext:(UIViewController *)viewController }); }]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"CANCEL" + UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"CANCEL" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { Mengine::Helper::dispatchMainThreadEvent([cancel]() { diff --git a/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingService.mm b/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingService.mm index 31bbea8a3a..1ba73d4ef5 100644 --- a/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingService.mm +++ b/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingService.mm @@ -18,7 +18,7 @@ ////////////////////////////////////////////////////////////////////////// AppleAppTrackingService::AppleAppTrackingService() : m_status( EAATA_NONE ) - , m_idfa( nil ) + , m_idfa( @"00000000-0000-0000-0000-000000000000" ) { } ////////////////////////////////////////////////////////////////////////// @@ -28,19 +28,19 @@ ////////////////////////////////////////////////////////////////////////// bool AppleAppTrackingService::_initializeService() { - m_idfa = @"00000000-0000-0000-0000-000000000000"; + //Empty return true; } ////////////////////////////////////////////////////////////////////////// void AppleAppTrackingService::_finalizeService() { - m_idfa = nil; + //Empty } ////////////////////////////////////////////////////////////////////////// void AppleAppTrackingService::authorization( const LambdaAuthorizationResponse & _response ) { - if(@available(iOS 14.0, *)) + if( @available(iOS 14.0, *) ) { LambdaAuthorizationResponse copy_response = _response; @@ -76,17 +76,17 @@ copy_response( status_copy, idfa_str ); }); }]; - } - else - { - m_status = EAATA_AUTHORIZED; - this->makeIDFA_(); - - const Char * idfa_str = [m_idfa UTF8String]; - - _response( m_status, idfa_str ); + return; } + + m_status = EAATA_AUTHORIZED; + + this->makeIDFA_(); + + const Char * idfa_str = [m_idfa UTF8String]; + + _response( m_status, idfa_str ); } ////////////////////////////////////////////////////////////////////////// void AppleAppTrackingService::getIDFA( EAppleAppTrackingAuthorization * const _status, Char * const _idfa ) const @@ -114,21 +114,36 @@ ////////////////////////////////////////////////////////////////////////// bool AppleAppTrackingService::isTrackingAllowed() const { - if(@available(iOS 14.5, *)) + if( @available(iOS 14.5, *) ) { - if( ATTrackingManager.trackingAuthorizationStatus == ATTrackingManagerAuthorizationStatusDenied ) + switch( ATTrackingManager.trackingAuthorizationStatus ) { - return false; + case ATTrackingManagerAuthorizationStatusAuthorized: + { + return true; + }break; + case ATTrackingManagerAuthorizationStatusDenied: + { + return false; + }break; + case ATTrackingManagerAuthorizationStatusNotDetermined: + { + return false; + }break; + case ATTrackingManagerAuthorizationStatusRestricted: + { + return false; + }break; } + + return false; } - else + + if( [iOSDetail isValidIDFA] == NO ) { - if( [iOSDetail isValidIDFA] == NO ) - { - return false; - } + return false; } - + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/POSIXThreadSystem/POSIXThreadSystem.cpp b/src/Systems/POSIXThreadSystem/POSIXThreadSystem.cpp index f64c57f9a9..2fec9ad4a2 100644 --- a/src/Systems/POSIXThreadSystem/POSIXThreadSystem.cpp +++ b/src/Systems/POSIXThreadSystem/POSIXThreadSystem.cpp @@ -179,7 +179,7 @@ namespace Mengine ////////////////////////////////////////////////////////////////////////// ThreadId POSIXThreadSystem::getCurrentThreadId() const { - pthread_t threadId = pthread_self(); + pthread_t threadId = ::pthread_self(); return (ThreadId)threadId; }