From dd68f1f6eff9aa1e7188d751b5a8caba31e62ec1 Mon Sep 17 00:00:00 2001 From: irov Date: Thu, 14 Nov 2024 02:08:13 +0200 Subject: [PATCH] add iOSPluginSessionIdDelegateInterface wip ios open delete account --- .../SDLApplication/SDLUIApplicationDelegate.h | 1 + .../SDLUIApplicationDelegate.mm | 33 +++++- src/Environment/Apple/AppleDetail.mm | 2 +- src/Environment/Apple/AppleEvent.h | 1 - src/Environment/Apple/AppleEvent.mm | 1 - src/Environment/iOS/CMakeLists.txt | 4 + src/Environment/iOS/iOSApplication.mm | 5 +- src/Environment/iOS/iOSDetail.h | 23 +++- src/Environment/iOS/iOSDetail.mm | 105 +++++++++++++++--- .../iOS/iOSPluginSessionIdDelegateInterface.h | 10 ++ src/Environment/iOS/iOSSessionIdParam.h | 11 ++ src/Environment/iOS/iOSSessionIdParam.mm | 5 + .../iOSUIMainApplicationDelegateInterface.h | 4 + .../iOSPlatform/iOSMailComposeDelegate.mm | 2 +- .../iOSPlatform/iOSPlatformService.mm | 31 ++++-- .../iOSPlatform/iOSPlatformSystem.mm | 4 - ...ppleFirebaseAnalyticsApplicationDelegate.h | 5 +- ...pleFirebaseAnalyticsApplicationDelegate.mm | 13 ++- ...leFirebaseCrashlyticsApplicationDelegate.h | 3 +- ...eFirebaseCrashlyticsApplicationDelegate.mm | 17 +-- .../AppleFirebaseCrashlyticsService.mm | 2 +- ...FirebaseRemoteConfigApplicationDelegate.mm | 9 +- ...oreInAppPurchaseProductsRequestDelegate.mm | 2 +- .../AppleFileSystem/AppleFileInputStream.mm | 2 +- .../AppleFileSystem/AppleFileSystem.mm | 6 +- 25 files changed, 240 insertions(+), 61 deletions(-) create mode 100644 src/Environment/iOS/iOSPluginSessionIdDelegateInterface.h create mode 100644 src/Environment/iOS/iOSSessionIdParam.h create mode 100644 src/Environment/iOS/iOSSessionIdParam.mm diff --git a/src/Applications/SDLApplication/SDLUIApplicationDelegate.h b/src/Applications/SDLApplication/SDLUIApplicationDelegate.h index fa38f0770e..049a2b73eb 100644 --- a/src/Applications/SDLApplication/SDLUIApplicationDelegate.h +++ b/src/Applications/SDLApplication/SDLUIApplicationDelegate.h @@ -15,6 +15,7 @@ @property (nonatomic, strong) NSMutableArray * m_pluginApplicationDelegates; @property (nonatomic, strong) NSMutableArray * m_pluginLoggerDelegates; +@property (nonatomic, strong) NSMutableArray * m_pluginSessionIdDelegates; @property (nonatomic, strong) NSMutableArray * m_pluginAdRevenueDelegates; @property (nonatomic, strong) NSMutableArray * m_pluginTransparencyConsentDelegates; diff --git a/src/Applications/SDLApplication/SDLUIApplicationDelegate.mm b/src/Applications/SDLApplication/SDLUIApplicationDelegate.mm index 323b3bf8e1..5e89c8a32b 100644 --- a/src/Applications/SDLApplication/SDLUIApplicationDelegate.mm +++ b/src/Applications/SDLApplication/SDLUIApplicationDelegate.mm @@ -25,6 +25,7 @@ - (id)init { self.m_pluginApplicationDelegates = [NSMutableArray array]; self.m_pluginLoggerDelegates = [NSMutableArray array]; + self.m_pluginSessionIdDelegates = [NSMutableArray array]; self.m_pluginAdRevenueDelegates = [NSMutableArray array]; self.m_pluginTransparencyConsentDelegates = [NSMutableArray array]; @@ -44,6 +45,10 @@ - (id)init { if ([delegate conformsToProtocol:@protocol(iOSPluginLoggerDelegateInterface)] == YES) { [self.m_pluginLoggerDelegates addObject:delegate]; } + + if ([delegate conformsToProtocol:@protocol(iOSPluginSessionIdDelegateInterface)] == YES) { + [self.m_pluginSessionIdDelegates addObject:delegate]; + } if ([delegate conformsToProtocol:@protocol(iOSPluginAdRevenueDelegateInterface)] == YES) { [self.m_pluginAdRevenueDelegates addObject:delegate]; @@ -67,6 +72,10 @@ - (id)init { return self.m_pluginLoggerDelegates; } +- (NSArray *)getPluginSessionIdDelegates { + return self.m_pluginSessionIdDelegates; +} + - (NSArray *)getPluginAdRevenueDelegates { return self.m_pluginAdRevenueDelegates; } @@ -104,6 +113,18 @@ - (void)log:(iOSLogRecordParam *)record { } } +- (void)setSessionId:(iOSSessionIdParam *)sessionId { + for (NSObject * delegate in self.m_pluginSessionIdDelegates) { + [delegate onSessionId:sessionId]; + } +} + +- (void)removeSessionData { + for (NSObject * delegate in self.m_pluginSessionIdDelegates) { + [delegate onRemoveSessionData]; + } +} + - (void)eventAdRevenue:(iOSAdRevenueParam *)revenue { for (NSObject * delegate in self.m_pluginAdRevenueDelegates) { [delegate onAdRevenue:revenue]; @@ -282,8 +303,10 @@ - (void)postFinishLaunch { SDL_iPhoneSetEventPump( SDL_FALSE ); - [iOSDetail alertWithTitle:@"Failed..." message:@"Mengine bootstraped application" callback:^{ - ::exit( EXIT_SUCCESS ); + [iOSDetail alertWithTitle:@"Failed..." + message:@"Mengine bootstraped application" + ok:^{ + ::exit( EXIT_FAILURE ); }]; return; @@ -298,8 +321,10 @@ - (void)postFinishLaunch { SDL_iPhoneSetEventPump( SDL_FALSE ); - [iOSDetail alertWithTitle:@"Failed..." message:@"Mengine initialized application" callback:^{ - ::exit( EXIT_SUCCESS ); + [iOSDetail alertWithTitle:@"Failed..." + message:@"Mengine initialized application" + ok:^{ + ::exit( EXIT_FAILURE ); }]; return; diff --git a/src/Environment/Apple/AppleDetail.mm b/src/Environment/Apple/AppleDetail.mm index f1519cc15f..2d568216b0 100644 --- a/src/Environment/Apple/AppleDetail.mm +++ b/src/Environment/Apple/AppleDetail.mm @@ -12,7 +12,7 @@ + (NSIDMessage)NSIdToString:(id _Nonnull) _value { + (NSErrorMessage)getMessageFromNSError:(NSError *) _error { NSString * message = [NSString stringWithFormat:@"[Error %ld Description: %@ Failure reason: %@ Recovery suggestion: %@" , [_error code] - , [_error localizedDescription] + , [_error description] , [_error localizedFailureReason] , [_error localizedRecoverySuggestion] ]; diff --git a/src/Environment/Apple/AppleEvent.h b/src/Environment/Apple/AppleEvent.h index 0667c8667f..23b0462166 100644 --- a/src/Environment/Apple/AppleEvent.h +++ b/src/Environment/Apple/AppleEvent.h @@ -9,7 +9,6 @@ @property (class, nonatomic, readonly) AppleEvent * EVENT_GDPR_PASS; @property (class, nonatomic, readonly) AppleEvent * EVENT_PUSH_TOKEN; @property (class, nonatomic, readonly) AppleEvent * EVENT_ADVERTISING_ID; -@property (class, nonatomic, readonly) AppleEvent * EVENT_SESSION_ID; @property (class, nonatomic, readonly) AppleEvent * EVENT_REMOTE_CONFIG_FETCH; @property (nonatomic, strong, readonly) NSString * name; diff --git a/src/Environment/Apple/AppleEvent.mm b/src/Environment/Apple/AppleEvent.mm index 0f9aa9bcd0..0d750c1814 100644 --- a/src/Environment/Apple/AppleEvent.mm +++ b/src/Environment/Apple/AppleEvent.mm @@ -15,7 +15,6 @@ + (AppleEvent *)NAME {\ DECLARE_APPLE_EVENT(EVENT_GDPR_PASS) DECLARE_APPLE_EVENT(EVENT_PUSH_TOKEN) DECLARE_APPLE_EVENT(EVENT_ADVERTISING_ID) -DECLARE_APPLE_EVENT(EVENT_SESSION_ID) DECLARE_APPLE_EVENT(EVENT_REMOTE_CONFIG_FETCH) - (instancetype)initWithName:(NSString *)name { diff --git a/src/Environment/iOS/CMakeLists.txt b/src/Environment/iOS/CMakeLists.txt index a4555aa839..ed6032de18 100644 --- a/src/Environment/iOS/CMakeLists.txt +++ b/src/Environment/iOS/CMakeLists.txt @@ -19,6 +19,9 @@ src iOSTransparencyConsentParam.h iOSTransparencyConsentParam.mm + iOSSessionIdParam.h + iOSSessionIdParam.mm + iOSAdRevenueParam.h iOSAdRevenueParam.mm @@ -27,6 +30,7 @@ src iOSUIMainApplicationDelegateInterface.h + iOSPluginSessionIdDelegateInterface.h iOSPluginAdRevenueDelegateInterface.h iOSPluginApplicationDelegateInterface.h iOSPluginTransparencyConsentDelegateInterface.h diff --git a/src/Environment/iOS/iOSApplication.mm b/src/Environment/iOS/iOSApplication.mm index effedce583..5524cb088d 100644 --- a/src/Environment/iOS/iOSApplication.mm +++ b/src/Environment/iOS/iOSApplication.mm @@ -76,7 +76,10 @@ - (void)setSessionId:(NSString * _Nonnull)sessionId { [AppleUserDefaults setStringForKey:@"mengine.session_id" value:self.m_sessionId]; - [iOSDetail eventNotify:AppleEvent.EVENT_SESSION_ID args:@[self.m_sessionId]]; + iOSSessionIdParam * param = [iOSSessionIdParam alloc]; + param.SESSION_ID = self.m_sessionId; + + [iOSDetail setSessionId:param]; } - (NSString * _Nonnull)getInstallKey { diff --git a/src/Environment/iOS/iOSDetail.h b/src/Environment/iOS/iOSDetail.h index 875342cfbf..916d8d7add 100644 --- a/src/Environment/iOS/iOSDetail.h +++ b/src/Environment/iOS/iOSDetail.h @@ -29,12 +29,31 @@ + (id)getUIProxyApplicationDelegate:(Class)delegateClass; + (void)eventNotify:(AppleEvent *)event args:(NSArray *)args; ++ (void)setSessionId:(iOSSessionIdParam *)sessionId; ++ (void)removeSessionData; + (void)adRevenue:(iOSAdRevenueParam *)revenue; + (void)transparencyConsent:(iOSTransparencyConsentParam *)consent; + (void)log:(iOSLogRecordParam *)record; + (NSString *)pathForTemporaryFileWithPrefix:(NSString *)prefix ext:(NSString *)ext; -+ (void)alertWithTitle:(NSString *)title message:(NSString *)message callback:(void (^)(void))callback; -+ (void)alertWithViewController:(UIViewController *)viewController title:(NSString *)title message:(NSString *)message callback:(void (^)(void))callback; ++ (void)alertWithTitle:(NSString *)title + message:(NSString *)message + ok:(void (^)(void) _Nonnull)ok; ++ (void)alertWithViewController:(UIViewController *)viewController + title:(NSString *)title + message:(NSString *)message + ok:(void (^)(void))ok; + ++ (void)showAreYouSureAlertDialogWithTitle:(NSString *)title + message:(NSString *)message + delay:(NSTimeInterval)delayMillis + yes:(void (^)(void) _Nonnull)yes + cancel:(void (^)(void) _Nonnull)cancel; ++ (void)showAreYouSureAlertDialogWithContext:(UIViewController *)viewController + title:(NSString *)title + message:(NSString *)message + delay:(NSTimeInterval)delayMillis + yes:(void (^)(void) _Nonnull)yes + cancel:(void (^)(void) _Nonnull)cancel; @end diff --git a/src/Environment/iOS/iOSDetail.mm b/src/Environment/iOS/iOSDetail.mm index 3ee5a249e4..0d304913e7 100644 --- a/src/Environment/iOS/iOSDetail.mm +++ b/src/Environment/iOS/iOSDetail.mm @@ -56,14 +56,14 @@ + (UIWindow *)getRootWindow { } + (UIView *)getRootView { - UIWindow *window = [self getRootWindow]; + UIWindow *window = [iOSDetail getRootWindow]; UIView *view = [window.subviews objectAtIndex:0]; return view; } + (UIViewController *)getRootViewController { - UIWindow *window = [self getRootWindow]; + UIWindow *window = [iOSDetail getRootWindow]; UIViewController *viewController = window.rootViewController; return viewController; @@ -102,15 +102,31 @@ + (id)getUIProxyApplicationDelegate:(Class)delegateClass { + (void)eventNotify:(AppleEvent *)event args:(NSArray *)args { [iOSDetail addMainQueueOperation:^{ - NSObject *delegate = [self getUIMainApplicationDelegate]; + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; [delegate notify:event arrayArgs:args]; }]; } ++ (void)setSessionId:(iOSSessionIdParam *)sessionId { + [iOSDetail addMainQueueOperation:^{ + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; + + [delegate setSessionId:sessionId]; + }]; +} + ++ (void)removeSessionData { + [iOSDetail addMainQueueOperation:^{ + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; + + [delegate removeSessionData]; + }]; +} + + (void)adRevenue:(iOSAdRevenueParam *)revenue { [iOSDetail addMainQueueOperation:^{ - NSObject *delegate = [self getUIMainApplicationDelegate]; + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; [delegate eventAdRevenue:revenue]; }]; @@ -118,7 +134,7 @@ + (void)adRevenue:(iOSAdRevenueParam *)revenue { + (void)transparencyConsent:(iOSTransparencyConsentParam *)consent { [iOSDetail addMainQueueOperation:^{ - NSObject *delegate = [self getUIMainApplicationDelegate]; + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; [delegate eventTransparencyConsent:consent]; }]; @@ -126,7 +142,7 @@ + (void)transparencyConsent:(iOSTransparencyConsentParam *)consent { + (void)log:(iOSLogRecordParam *)record { [iOSDetail addMainQueueOperation:^{ - NSObject *delegate = [self getUIMainApplicationDelegate]; + NSObject *delegate = [iOSDetail getUIMainApplicationDelegate]; [delegate log:record]; }]; @@ -145,21 +161,26 @@ + (NSString *)pathForTemporaryFileWithPrefix:(NSString *)prefix ext:(NSString *) return result; } -+ (void)alertWithTitle:(NSString *)title message:(NSString *)message callback:(void (^)(void))callback { - UIViewController *rootViewController = [self getRootViewController]; - [self alertWithViewController:rootViewController title:title message:message callback:callback]; ++ (void)alertWithTitle:(NSString *)title message:(NSString *)message ok:(void (^)(void) _Nonnull)ok { + UIViewController * viewController = [iOSDetail getRootViewController]; + + [iOSDetail alertWithViewController:viewController + title:title + message:message + ok:ok]; } -+ (void)alertWithViewController:(UIViewController *)viewController title:(NSString *)title message:(NSString *)message callback:(void (^)(void))callback { ++ (void)alertWithViewController:(UIViewController *)viewController + title:(NSString *)title + message:(NSString *)message + ok:(void (^)(void) _Nonnull)ok { if (viewController == nil) { return; } UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - if (callback) { - callback(); - } + ok(); }]; [alertController addAction:okAction]; @@ -169,4 +190,62 @@ + (void)alertWithViewController:(UIViewController *)viewController title:(NSStri }); } ++ (void)showAreYouSureAlertDialogWithTitle:(NSString *)title + message:(NSString *)message + delay:(NSTimeInterval)delayMillis + yes:(void (^)(void) _Nonnull)yes + cancel:(void (^)(void) _Nonnull)cancel { + UIViewController * viewController = [iOSDetail getRootViewController]; + + [iOSDetail showAreYouSureAlertDialogWithContext:viewController + title:title + message:message + delay:delayMillis + yes:yes + cancel:cancel]; +} + ++ (void)showAreYouSureAlertDialogWithContext:(UIViewController *)viewController + title:(NSString *)title + message:(NSString *)message + delay:(NSTimeInterval)delayMillis + yes:(void (^)(void) _Nonnull)yes + cancel:(void (^)(void) _Nonnull)cancel { + NSString * areYouSureText = @"\n\nAre you sure?"; + NSString * fullMessage = [message stringByAppendingString:areYouSureText]; + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:title + message:fullMessage + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * _Nonnull action) { + yes(); + }]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"CANCEL" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * _Nonnull action) { + cancel(); + }]; + + [alert addAction:cancelAction]; + [alert addAction:yesAction]; + + if (delayMillis > 0) { + yesAction.enabled = NO; + yesAction.accessibilityHint = @"Disabled temporarily"; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayMillis * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ + yesAction.enabled = YES; + yesAction.accessibilityHint = nil; + }); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [viewController presentViewController:alert animated:YES completion:nil]; + }); +} + @end diff --git a/src/Environment/iOS/iOSPluginSessionIdDelegateInterface.h b/src/Environment/iOS/iOSPluginSessionIdDelegateInterface.h new file mode 100644 index 0000000000..f10829a78e --- /dev/null +++ b/src/Environment/iOS/iOSPluginSessionIdDelegateInterface.h @@ -0,0 +1,10 @@ +#include "Config/Config.h" + +#import "Environment/iOS/iOSSessionIdParam.h" + +@protocol iOSPluginSessionIdDelegateInterface + +- (void)onSessionId:(iOSSessionIdParam *)session; +- (void)onRemoveSessionData; + +@end diff --git a/src/Environment/iOS/iOSSessionIdParam.h b/src/Environment/iOS/iOSSessionIdParam.h new file mode 100644 index 0000000000..519b5c3946 --- /dev/null +++ b/src/Environment/iOS/iOSSessionIdParam.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Config/Config.h" + +#import + +@interface iOSSessionIdParam : NSObject + +@property (nonatomic, strong) NSString * _Nonnull SESSION_ID; + +@end diff --git a/src/Environment/iOS/iOSSessionIdParam.mm b/src/Environment/iOS/iOSSessionIdParam.mm new file mode 100644 index 0000000000..903d9d33bb --- /dev/null +++ b/src/Environment/iOS/iOSSessionIdParam.mm @@ -0,0 +1,5 @@ +#import "iOSSessionIdParam.h" + +@implementation iOSSessionIdParam + +@end diff --git a/src/Environment/iOS/iOSUIMainApplicationDelegateInterface.h b/src/Environment/iOS/iOSUIMainApplicationDelegateInterface.h index 26ac1c7f0d..36b6a01ff1 100644 --- a/src/Environment/iOS/iOSUIMainApplicationDelegateInterface.h +++ b/src/Environment/iOS/iOSUIMainApplicationDelegateInterface.h @@ -2,6 +2,7 @@ #import "Environment/iOS/iOSPluginApplicationDelegateInterface.h" #import "Environment/iOS/iOSPluginLoggerDelegateInterface.h" +#import "Environment/iOS/iOSPluginSessionIdDelegateInterface.h" #import "Environment/iOS/iOSPluginAdRevenueDelegateInterface.h" #import "Environment/iOS/iOSPluginTransparencyConsentDelegateInterface.h" @@ -11,6 +12,7 @@ - (NSArray *)getPluginApplicationDelegates; - (NSArray *)getPluginLoggerDelegates; +- (NSArray *)getPluginSessionIdDelegates; - (NSArray *)getPluginAdRevenueDelegates; - (NSArray *)getPluginTransparencyConsentDelegates; @@ -19,6 +21,8 @@ - (void)log:(iOSLogRecordParam *)record; +- (void)setSessionId:(iOSSessionIdParam *)sessionId; +- (void)removeSessionData; - (void)eventAdRevenue:(iOSAdRevenueParam *)revenue; - (void)eventTransparencyConsent:(iOSTransparencyConsentParam *)consent; diff --git a/src/Platforms/iOSPlatform/iOSMailComposeDelegate.mm b/src/Platforms/iOSPlatform/iOSMailComposeDelegate.mm index 0283ecfa93..57c460795d 100644 --- a/src/Platforms/iOSPlatform/iOSMailComposeDelegate.mm +++ b/src/Platforms/iOSPlatform/iOSMailComposeDelegate.mm @@ -29,7 +29,7 @@ - (void)mailComposeController:(MFMailComposeViewController *)controller didFinis break; case MFMailComposeResultFailed: LOGGER_ERROR( "MFMailComposeResultFailed: The email message was not saved or queued, possibly due to an error [%s]" - , [[error localizedDescription] UTF8String] + , [[error description] UTF8String] ); break; default: diff --git a/src/Platforms/iOSPlatform/iOSPlatformService.mm b/src/Platforms/iOSPlatform/iOSPlatformService.mm index 7641f59dee..b7db688c4c 100644 --- a/src/Platforms/iOSPlatform/iOSPlatformService.mm +++ b/src/Platforms/iOSPlatform/iOSPlatformService.mm @@ -874,12 +874,14 @@ static void SDL_LogOutputFunction( void * userdata, int category, SDL_LogPriorit NSURL * ns_url = [NSURL URLWithString:@(_url)]; - if( [[UIApplication sharedApplication]canOpenURL:ns_url] == NO ) + if( [[UIApplication sharedApplication] canOpenURL:ns_url] == NO ) { return false; } - [[UIApplication sharedApplication]openURL:ns_url options:@{} completionHandler:^(BOOL success) { + [[UIApplication sharedApplication] openURL:ns_url + options:@{} + completionHandler:^(BOOL success) { //ToDo callback }]; @@ -898,7 +900,10 @@ static void SDL_LogOutputFunction( void * userdata, int category, SDL_LogPriorit if( [MFMailComposeViewController canSendMail] == NO ) { - [iOSDetail alertWithViewController:viewController title:@"Yikes." message:@"Log into your mailbox using the standard Mail app" callback:^{}]; + [iOSDetail alertWithViewController:viewController + title:@"Yikes." + message:@"Log into your mailbox using the standard Mail app" + ok:^{}]; return false; } @@ -917,7 +922,9 @@ static void SDL_LogOutputFunction( void * userdata, int category, SDL_LogPriorit [mailCompose setSubject:@(_subject)]; [mailCompose setMessageBody:@(_body) isHTML:NO]; - [viewController presentViewController:mailCompose animated:YES completion:^ { + [viewController presentViewController:mailCompose + animated:YES + completion:^ { //ToDo callback }] ; @@ -927,10 +934,20 @@ static void SDL_LogOutputFunction( void * userdata, int category, SDL_LogPriorit bool iOSPlatformService::openDeleteAccount() { LOGGER_INFO( "platform", "open delete account" ); + + [iOSDetail showAreYouSureAlertDialogWithTitle:@"Delete Account" + message:@"Click 'YES' will delete all account data. All game progress, virtual goods, and currency will be permanently removed and unrecoverable." + delay:3000 + yes:^() { + LOGGER_MESSAGE("delete account [YES]"); + + } + cancel: ^() { + LOGGER_MESSAGE("delete account [CANCEL]"); + + }]; - //Empty - - return false; + return true; } ////////////////////////////////////////////////////////////////////////// void iOSPlatformService::stopPlatform() diff --git a/src/Platforms/iOSPlatform/iOSPlatformSystem.mm b/src/Platforms/iOSPlatform/iOSPlatformSystem.mm index 2f5455214b..fa7f3cf14c 100644 --- a/src/Platforms/iOSPlatform/iOSPlatformSystem.mm +++ b/src/Platforms/iOSPlatform/iOSPlatformSystem.mm @@ -11,8 +11,6 @@ namespace Detail { ////////////////////////////////////////////////////////////////////////// -#if !defined(MENGINE_PLATFORM_UWP) - ////////////////////////////////////////////////////////////////////////// static void * SDL_malloc_func( size_t size ) { void * p = Helper::allocateMemory( size, "SDL" ); @@ -39,8 +37,6 @@ static void SDL_free_func( void * mem ) Helper::deallocateMemory( mem, "SDL" ); } ////////////////////////////////////////////////////////////////////////// -#endif - ////////////////////////////////////////////////////////////////////////// } ////////////////////////////////////////////////////////////////////////// iOSPlatformSystem::iOSPlatformSystem() diff --git a/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.h b/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.h index bf4ca128fd..cbeb52e225 100644 --- a/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.h +++ b/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.h @@ -1,8 +1,11 @@ +#pragma once + #import "Environment/iOS/iOSPluginApplicationDelegateInterface.h" +#import "Environment/iOS/iOSPluginSessionIdDelegateInterface.h" #import "Environment/iOS/iOSPluginAdRevenueDelegateInterface.h" #import "Environment/iOS/iOSPluginTransparencyConsentDelegateInterface.h" -@interface AppleFirebaseAnalyticsApplicationDelegate : NSObject +@interface AppleFirebaseAnalyticsApplicationDelegate : NSObject @end diff --git a/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.mm b/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.mm index f0b52ea1e3..9440550ace 100644 --- a/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.mm +++ b/src/Plugins/AppleFirebaseAnalyticsPlugin/AppleFirebaseAnalyticsApplicationDelegate.mm @@ -19,12 +19,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } -- (void)onEvent:(AppleEvent *)event args:(NSArray *)args { - if (event == AppleEvent.EVENT_SESSION_ID) { - NSString * sessionId = args[0]; - - [FIRAnalytics setUserID:sessionId]; - } +- (void)onSessionId:(iOSSessionIdParam *)session { + [FIRAnalytics setUserID:session.SESSION_ID]; +} + +- (void)onRemoveSessionData { + [FIRAnalytics resetAnalyticsData]; + [FIRAnalytics setUserID:nil]; } #pragma mark - iOSPluginAdRevenueDelegateInterface diff --git a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.h b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.h index 65a23e3c0f..d78c07b765 100644 --- a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.h +++ b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.h @@ -1,8 +1,9 @@ #pragma once #import "Environment/iOS/iOSPluginApplicationDelegateInterface.h" +#import "Environment/iOS/iOSPluginSessionIdDelegateInterface.h" #import "Environment/iOS/iOSPluginLoggerDelegateInterface.h" -@interface AppleFirebaseCrashlyticsApplicationDelegate : NSObject +@interface AppleFirebaseCrashlyticsApplicationDelegate : NSObject @end diff --git a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.mm b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.mm index 460efb8f87..8e7fce35dc 100644 --- a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.mm +++ b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsApplicationDelegate.mm @@ -21,12 +21,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } -- (void)onEvent:(AppleEvent *)event args:(NSArray *)args { - if (event == AppleEvent.EVENT_SESSION_ID) { - NSString * sessionId = args[0]; - - [[FIRCrashlytics crashlytics] setUserID:sessionId]; - } +- (void)onSessionId:(iOSSessionIdParam *)session { + [[FIRCrashlytics crashlytics] setUserID:session.SESSION_ID]; +} + +- (void)onRemoveSessionData { + [[FIRCrashlytics crashlytics] deleteUnsentReports]; + [[FIRCrashlytics crashlytics] setUserID:nil]; } - (void)onLogger:(iOSLogRecordParam *)record { @@ -34,7 +35,7 @@ - (void)onLogger:(iOSLogRecordParam *)record { case Mengine::LM_ERROR: { if ((record.LOG_FILTER & Mengine::LFILTER_EXCEPTION) == Mengine::LFILTER_EXCEPTION) { NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: record.LOG_DATA + NSLocalizedDescriptionKey:record.LOG_DATA }; NSError * error = [NSError errorWithDomain:record.LOG_CATEGORY @@ -48,7 +49,7 @@ - (void)onLogger:(iOSLogRecordParam *)record { }break; case Mengine::LM_FATAL: { NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: record.LOG_DATA + NSLocalizedDescriptionKey:record.LOG_DATA }; NSError * error = [NSError errorWithDomain:record.LOG_CATEGORY diff --git a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsService.mm b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsService.mm index 1045075fb8..4d19096e37 100644 --- a/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsService.mm +++ b/src/Plugins/AppleFirebaseCrashlyticsPlugin/AppleFirebaseCrashlyticsService.mm @@ -78,7 +78,7 @@ ); NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: @(_name.c_str()) + NSLocalizedDescriptionKey:@(_name.c_str()) }; NSError * error = [NSError errorWithDomain:@("com.mengine.firebase") diff --git a/src/Plugins/AppleFirebaseRemoteConfigPlugin/AppleFirebaseRemoteConfigApplicationDelegate.mm b/src/Plugins/AppleFirebaseRemoteConfigPlugin/AppleFirebaseRemoteConfigApplicationDelegate.mm index 746ff30877..92e49ae2b2 100644 --- a/src/Plugins/AppleFirebaseRemoteConfigPlugin/AppleFirebaseRemoteConfigApplicationDelegate.mm +++ b/src/Plugins/AppleFirebaseRemoteConfigPlugin/AppleFirebaseRemoteConfigApplicationDelegate.mm @@ -13,6 +13,7 @@ @implementation AppleFirebaseRemoteConfigApplicationDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] init]; remoteConfigSettings.minimumFetchInterval = MENGINE_DEBUG_VALUE(0, 3600); + [[FIRRemoteConfig remoteConfig] setConfigSettings:remoteConfigSettings]; [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName:@MENGINE_FIREBASE_REMOTECONFIG_PLIST_NAME]; @@ -21,7 +22,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( switch (status) { case FIRRemoteConfigFetchStatusNoFetchYet: NSLog( @"FIRRemoteConfigFetchStatusNoFetchYet: %@" - , [error localizedDescription] + , [error description] ); break; @@ -32,7 +33,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( if (error != nil) { NSLog( @"FIRRemoteConfigFetchStatusSuccess activate error: %@" - , [error localizedDescription] + , [error description] ); return; @@ -45,13 +46,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( break; case FIRRemoteConfigFetchStatusFailure: NSLog( @"FIRRemoteConfigFetchStatusFailure: %@" - , [error localizedDescription] + , [error description] ); break; case FIRRemoteConfigFetchStatusThrottled: NSLog( @"FIRRemoteConfigFetchStatusThrottled: %@" - , [error localizedDescription] + , [error description] ); break; diff --git a/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseProductsRequestDelegate.mm b/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseProductsRequestDelegate.mm index 2e37c6a8ee..9318f36ee5 100644 --- a/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseProductsRequestDelegate.mm +++ b/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseProductsRequestDelegate.mm @@ -69,7 +69,7 @@ - (void)requestDidFinish:(SKRequest *)request { ////////////////////////////////////////////////////////////////////////// - (void)request:(SKRequest *)request didFailWithError:(NSError *)error { LOGGER_MESSAGE( "[SKProductsRequestDelegate] request didFailWithError: %s" - , [error.localizedDescription UTF8String] + , [error.description UTF8String] ); Mengine::AppleStoreInAppPurchaseProductsResponseInterfacePtr cb_copy = self.m_cb; diff --git a/src/Systems/AppleFileSystem/AppleFileInputStream.mm b/src/Systems/AppleFileSystem/AppleFileInputStream.mm index 72286f9765..a558bc463e 100644 --- a/src/Systems/AppleFileSystem/AppleFileInputStream.mm +++ b/src/Systems/AppleFileSystem/AppleFileInputStream.mm @@ -135,7 +135,7 @@ { LOGGER_ERROR( "invalid open file '%s' error '%s'" , _fullPath - , [error.localizedDescription UTF8String] + , [error.description UTF8String] ); return false; diff --git a/src/Systems/AppleFileSystem/AppleFileSystem.mm b/src/Systems/AppleFileSystem/AppleFileSystem.mm index f167e2e7a1..fcaf5155b8 100644 --- a/src/Systems/AppleFileSystem/AppleFileSystem.mm +++ b/src/Systems/AppleFileSystem/AppleFileSystem.mm @@ -223,7 +223,7 @@ static bool isDirectoryFullpath( const Char * _fullpath ) { LOGGER_ERROR("Failed to remove file: %s error: %s" , pathCorrect - , [error.localizedDescription UTF8String] + , [error.description UTF8String] ); return false; @@ -249,7 +249,7 @@ static bool isDirectoryFullpath( const Char * _fullpath ) { LOGGER_ERROR("Failed to remove existing file: %s error: %s" , newPathCorrect - , [remove_error.localizedDescription UTF8String] + , [remove_error.description UTF8String] ); return false; @@ -262,7 +262,7 @@ static bool isDirectoryFullpath( const Char * _fullpath ) LOGGER_ERROR("Failed to move file from: %s to: %s error: %s" , oldPathCorrect , newPathCorrect - , [move_error.localizedDescription UTF8String] + , [move_error.description UTF8String] ); return false;