From 71d089b60adc294fef43844f7cf669ba5602a5e1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 9 Dec 2024 11:30:05 +0100 Subject: [PATCH] chore(ios): remove unused code from old migration --- .../common/{RNAppModule.m => RNAppModule.mm} | 55 ----------- ios/RNGoogleMobileAds/common/RNJSON.h | 34 ------- ios/RNGoogleMobileAds/common/RNJSON.m | 93 ------------------ ios/RNGoogleMobileAds/common/RNMeta.h | 30 ------ ios/RNGoogleMobileAds/common/RNMeta.m | 61 ------------ ios/RNGoogleMobileAds/common/RNPreferences.h | 44 --------- ios/RNGoogleMobileAds/common/RNPreferences.m | 94 ------------------- ...RCTEventEmitter.m => RNRCTEventEmitter.mm} | 0 ios/RNGoogleMobileAds/common/RNSharedUtils.h | 4 - .../{RNSharedUtils.m => RNSharedUtils.mm} | 21 ----- 10 files changed, 436 deletions(-) rename ios/RNGoogleMobileAds/common/{RNAppModule.m => RNAppModule.mm} (59%) delete mode 100644 ios/RNGoogleMobileAds/common/RNJSON.h delete mode 100644 ios/RNGoogleMobileAds/common/RNJSON.m delete mode 100644 ios/RNGoogleMobileAds/common/RNMeta.h delete mode 100644 ios/RNGoogleMobileAds/common/RNMeta.m delete mode 100644 ios/RNGoogleMobileAds/common/RNPreferences.h delete mode 100644 ios/RNGoogleMobileAds/common/RNPreferences.m rename ios/RNGoogleMobileAds/common/{RNRCTEventEmitter.m => RNRCTEventEmitter.mm} (100%) rename ios/RNGoogleMobileAds/common/{RNSharedUtils.m => RNSharedUtils.mm} (60%) diff --git a/ios/RNGoogleMobileAds/common/RNAppModule.m b/ios/RNGoogleMobileAds/common/RNAppModule.mm similarity index 59% rename from ios/RNGoogleMobileAds/common/RNAppModule.m rename to ios/RNGoogleMobileAds/common/RNAppModule.mm index 09a72a1f..8f844aa4 100644 --- a/ios/RNGoogleMobileAds/common/RNAppModule.m +++ b/ios/RNGoogleMobileAds/common/RNAppModule.mm @@ -18,9 +18,6 @@ #import #import "RNAppModule.h" -#import "RNJSON.h" -#import "RNMeta.h" -#import "RNPreferences.h" #import "RNRCTEventEmitter.h" #import "RNSharedUtils.h" @@ -51,58 +48,6 @@ - (void)invalidate { [[RNRCTEventEmitter shared] invalidate]; } -#pragma mark - -#pragma mark META Methods - -RCT_EXPORT_METHOD(metaGetAll - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - resolve([RNMeta getAll]); -} - -#pragma mark - -#pragma mark JSON Methods - -RCT_EXPORT_METHOD(jsonGetAll - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - resolve([[RNJSON shared] getAll]); -} - -#pragma mark - -#pragma mark Preference Methods - -RCT_EXPORT_METHOD(preferencesSetBool - : (NSString *)key boolValue - : (BOOL)boolValue resolver - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - [[RNPreferences shared] setBooleanValue:key boolValue:boolValue]; - resolve([NSNull null]); -} - -RCT_EXPORT_METHOD(preferencesSetString - : (NSString *)key stringValue - : (NSString *)stringValue resolver - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - [[RNPreferences shared] setStringValue:key stringValue:stringValue]; - resolve([NSNull null]); -} - -RCT_EXPORT_METHOD(preferencesGetAll - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - resolve([[RNPreferences shared] getAll]); -} - -RCT_EXPORT_METHOD(preferencesClearAll - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) { - [[RNPreferences shared] clearAll]; - resolve([NSNull null]); -} - #pragma mark - #pragma mark Event Methods diff --git a/ios/RNGoogleMobileAds/common/RNJSON.h b/ios/RNGoogleMobileAds/common/RNJSON.h deleted file mode 100644 index 5e399747..00000000 --- a/ios/RNGoogleMobileAds/common/RNJSON.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface RNJSON : NSObject - -- (BOOL)contains:(NSString *)key; - -- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue; - -- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue; - -- (NSDictionary *)getAll; - -- (NSString *)getRawJSON; - -+ (RNJSON *)shared; - -@end diff --git a/ios/RNGoogleMobileAds/common/RNJSON.m b/ios/RNGoogleMobileAds/common/RNJSON.m deleted file mode 100644 index 95dd93cd..00000000 --- a/ios/RNGoogleMobileAds/common/RNJSON.m +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "RNJSON.h" - -@interface RNJSON () -@property(nonatomic, strong) NSDictionary *googleMobileAdsJson; -@end - -@implementation RNJSON - -+ (instancetype)shared { - static dispatch_once_t once; - static RNJSON *sharedInstance; - - dispatch_once(&once, ^{ - sharedInstance = [[RNJSON alloc] init]; - NSString *__nullable googleMobileAdsJsonRaw = - [[NSBundle mainBundle].infoDictionary valueForKey:@"googleMobileAds_json_raw"]; - - if (googleMobileAdsJsonRaw == nil) { - sharedInstance.googleMobileAdsJson = [NSDictionary dictionary]; - return; - } - - NSData *data = [[NSData alloc] initWithBase64EncodedString:googleMobileAdsJsonRaw options:0]; - - if (data == nil) { - sharedInstance.googleMobileAdsJson = [NSDictionary dictionary]; - return; - } - - NSError *jsonError = nil; - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data - options:0 - error:&jsonError]; - if (jsonError != nil) { - sharedInstance.googleMobileAdsJson = [NSDictionary dictionary]; - return; - } - - sharedInstance.googleMobileAdsJson = dictionary; - }); - - return sharedInstance; -} - -- (BOOL)contains:(NSString *)key { - return [_googleMobileAdsJson valueForKey:key] != nil; -} - -- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue { - if ([_googleMobileAdsJson valueForKey:key] == nil) return defaultValue; - NSNumber *boolean = [_googleMobileAdsJson valueForKey:key]; - return [boolean boolValue]; -} - -- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue { - if ([_googleMobileAdsJson valueForKey:key] == nil) return defaultValue; - NSString *string = [_googleMobileAdsJson valueForKey:key]; - return string; -} - -- (NSDictionary *)getAll { - return [[NSDictionary alloc] initWithDictionary:_googleMobileAdsJson copyItems:YES]; -} - -- (NSString *)getRawJSON { - NSString *__nullable googleMobileAdsJsonRaw = - [[NSBundle mainBundle].infoDictionary valueForKey:@"googleMobileAds_json_raw"]; - if (googleMobileAdsJsonRaw == nil) { - return @"{}"; - } - - NSData *data = [[NSData alloc] initWithBase64EncodedString:googleMobileAdsJsonRaw options:0]; - return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - ; -} -@end diff --git a/ios/RNGoogleMobileAds/common/RNMeta.h b/ios/RNGoogleMobileAds/common/RNMeta.h deleted file mode 100644 index f9557c8d..00000000 --- a/ios/RNGoogleMobileAds/common/RNMeta.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface RNMeta : NSObject - -+ (BOOL)contains:(NSString *)key; - -+ (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue; - -+ (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue; - -+ (NSDictionary *)getAll; - -@end diff --git a/ios/RNGoogleMobileAds/common/RNMeta.m b/ios/RNGoogleMobileAds/common/RNMeta.m deleted file mode 100644 index 29682976..00000000 --- a/ios/RNGoogleMobileAds/common/RNMeta.m +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "RNMeta.h" - -@interface RNMeta () -@property(nonatomic, strong) NSDictionary *firebaseJson; -@end - -NSString *const RNMetaPrefix = @"rn_"; - -@implementation RNMeta - -+ (BOOL)contains:(NSString *)key { - id keyValue = - [[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]]; - return keyValue != nil; -} - -+ (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue { - NSNumber *keyValue = - [[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]]; - if (keyValue == nil) return defaultValue; - return [keyValue boolValue]; -} - -+ (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue { - NSString *keyValue = - [[NSBundle mainBundle].infoDictionary valueForKey:[RNMetaPrefix stringByAppendingString:key]]; - if (keyValue == nil) return defaultValue; - return keyValue; -} - -+ (NSDictionary *)getAll { - NSMutableDictionary *allMetaValues = [NSMutableDictionary dictionary]; - - NSArray *keys = [[NSBundle mainBundle].infoDictionary allKeys]; - for (NSString *key in keys) { - if ([key hasPrefix:RNMetaPrefix]) { - allMetaValues[key] = [NSBundle mainBundle].infoDictionary[key]; - } - } - - return allMetaValues; -} - -@end diff --git a/ios/RNGoogleMobileAds/common/RNPreferences.h b/ios/RNGoogleMobileAds/common/RNPreferences.h deleted file mode 100644 index 324a3378..00000000 --- a/ios/RNGoogleMobileAds/common/RNPreferences.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import - -@interface RNPreferences : NSObject - -- (BOOL)contains:(NSString *)key; - -- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue; - -- (void)setBooleanValue:(NSString *)key boolValue:(BOOL)boolValue; - -- (void)setIntegerValue:(NSString *)key integerValue:(NSInteger *)integerValue; - -- (void)setStringValue:(NSString *)key stringValue:(NSString *)stringValue; - -- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue; - -- (NSInteger *)getIntegerValue:(NSString *)key defaultValue:(NSInteger *)defaultValue; - -- (NSDictionary *)getAll; - -- (void)clearAll; - -- (void)remove:(NSString *)key; - -+ (RNPreferences *)shared; - -@end diff --git a/ios/RNGoogleMobileAds/common/RNPreferences.m b/ios/RNGoogleMobileAds/common/RNPreferences.m deleted file mode 100644 index 4165026e..00000000 --- a/ios/RNGoogleMobileAds/common/RNPreferences.m +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#import "RNPreferences.h" - -@interface RNPreferences () -@property(nonatomic, strong) NSUserDefaults *userDefaults; -@end - -static NSString *const RNDomainIdentifier = @"io.invertase.common"; - -@implementation RNPreferences - -static RNPreferences *sharedInstance; - -+ (void)load { - sharedInstance = [[RNPreferences alloc] init]; -} - -- (instancetype)init { - self = [super init]; - - if (self) { - _userDefaults = [[NSUserDefaults alloc] initWithSuiteName:RNDomainIdentifier]; - } - - return self; -} - -- (BOOL)contains:(NSString *)key { - return [_userDefaults objectForKey:key] != nil; -} - -- (BOOL)getBooleanValue:(NSString *)key defaultValue:(BOOL)defaultValue { - if ([_userDefaults objectForKey:key] == nil) return defaultValue; - return [_userDefaults boolForKey:key]; -} - -- (void)setBooleanValue:(NSString *)key boolValue:(BOOL)boolValue { - [_userDefaults setBool:boolValue forKey:key]; - [_userDefaults synchronize]; -} - -- (void)setIntegerValue:(NSString *)key integerValue:(NSInteger *)integerValue { - [_userDefaults setInteger:(NSInteger)integerValue forKey:key]; - [_userDefaults synchronize]; -} - -- (NSInteger *)getIntegerValue:(NSString *)key defaultValue:(NSInteger *)defaultValue { - if ([_userDefaults objectForKey:key] == nil) return defaultValue; - return (NSInteger *)[_userDefaults integerForKey:key]; -} - -- (NSString *)getStringValue:(NSString *)key defaultValue:(NSString *)defaultValue { - if ([_userDefaults objectForKey:key] == nil) return defaultValue; - return [_userDefaults stringForKey:key]; -} - -- (void)setStringValue:(NSString *)key stringValue:(NSString *)stringValue { - [_userDefaults setValue:stringValue forKey:key]; - [_userDefaults synchronize]; -} - -- (NSDictionary *)getAll { - return [_userDefaults dictionaryRepresentation]; -} - -- (void)clearAll { - [_userDefaults removePersistentDomainForName:RNDomainIdentifier]; -} - -- (void)remove:(NSString *)key { - [_userDefaults removeObjectForKey:key]; -} - -+ (RNPreferences *)shared { - return sharedInstance; -} - -@end diff --git a/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m b/ios/RNGoogleMobileAds/common/RNRCTEventEmitter.mm similarity index 100% rename from ios/RNGoogleMobileAds/common/RNRCTEventEmitter.m rename to ios/RNGoogleMobileAds/common/RNRCTEventEmitter.mm diff --git a/ios/RNGoogleMobileAds/common/RNSharedUtils.h b/ios/RNGoogleMobileAds/common/RNSharedUtils.h index 6ab0653c..50902c9f 100644 --- a/ios/RNGoogleMobileAds/common/RNSharedUtils.h +++ b/ios/RNGoogleMobileAds/common/RNSharedUtils.h @@ -36,13 +36,9 @@ #pragma mark - #pragma mark Methods -+ (void)sendJSEvent:name:(NSString *)name body:(NSDictionary *)body; - + (void)rejectPromiseWithUserInfo:(RCTPromiseRejectBlock)reject userInfo:(NSMutableDictionary *)userInfo; -+ (NSString *)getISO8601String:(NSDate *)date; - @end #endif diff --git a/ios/RNGoogleMobileAds/common/RNSharedUtils.m b/ios/RNGoogleMobileAds/common/RNSharedUtils.mm similarity index 60% rename from ios/RNGoogleMobileAds/common/RNSharedUtils.m rename to ios/RNGoogleMobileAds/common/RNSharedUtils.mm index d4831264..f3863a2d 100644 --- a/ios/RNGoogleMobileAds/common/RNSharedUtils.m +++ b/ios/RNGoogleMobileAds/common/RNSharedUtils.mm @@ -16,7 +16,6 @@ */ #import "RNSharedUtils.h" -#import "RNRCTEventEmitter.h" #pragma mark - #pragma mark Constants @@ -33,24 +32,4 @@ + (void)rejectPromiseWithUserInfo:(RCTPromiseRejectBlock)reject reject(userInfo[@"code"], userInfo[@"message"], error); } -+ (void)sendJSEvent:name:(NSString *)name body:(NSDictionary *)body { - NSMutableDictionary *newBody = [body mutableCopy]; - [[RNRCTEventEmitter shared] sendEventWithName:name body:newBody]; -} - -+ (NSString *)getISO8601String:(NSDate *)date { - static NSDateFormatter *formatter = nil; - - if (!formatter) { - formatter = [[NSDateFormatter alloc] init]; - [formatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]]; - formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; - [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"]; - } - - NSString *iso8601String = [formatter stringFromDate:date]; - - return [iso8601String stringByAppendingString:@"Z"]; -} - @end