diff --git a/app/index.js b/app/index.js index 132116e62..0eba137da 100644 --- a/app/index.js +++ b/app/index.js @@ -605,9 +605,6 @@ export default class Root extends React.Component { } init = async() => { - if (isIOS) { - await RNUserDefaults.setName('group.ios.chat.rocket'); - } RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme); const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]); const parsedDeepLinkingURL = parseDeepLinking(deepLinking); diff --git a/app/share.js b/app/share.js index 3d2484a7d..5ab50599a 100644 --- a/app/share.js +++ b/app/share.js @@ -15,7 +15,7 @@ import { import Navigation from './lib/ShareNavigation'; import store from './lib/createStore'; import sharedStyles from './views/Styles'; -import { isNotch, isIOS, supportSystemTheme } from './utils/deviceInfo'; +import { isNotch, supportSystemTheme } from './utils/deviceInfo'; import { defaultHeader, onNavigationStateChange, cardStyle } from './utils/navigation'; import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat'; import { ThemeContext } from './theme'; @@ -77,9 +77,6 @@ class Root extends React.Component { } init = async() => { - if (isIOS) { - await RNUserDefaults.setName('group.ios.chat.rocket'); - } RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme); const currentServer = await RNUserDefaults.get('currentServer'); const token = await RNUserDefaults.get(RocketChat.TOKEN_KEY); diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 2fa005932..f5c448138 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -397,7 +397,7 @@ PODS: - React - RNScreens (2.0.0-alpha.3): - React - - RNUserDefaults (1.7.0): + - RNUserDefaults (1.8.1): - React - RNVectorIcons (6.6.0): - React @@ -786,7 +786,7 @@ SPEC CHECKSUMS: RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494 RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f - RNUserDefaults: af71a1cdf1c12baf8210bc741c65f5faba9826d6 + RNUserDefaults: c421fd97ad06b35c16608c5d0fe675db353f632d RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca diff --git a/ios/Pods/Local Podspecs/RNUserDefaults.podspec.json b/ios/Pods/Local Podspecs/RNUserDefaults.podspec.json index 07aed251b..b54949a2b 100644 --- a/ios/Pods/Local Podspecs/RNUserDefaults.podspec.json +++ b/ios/Pods/Local Podspecs/RNUserDefaults.podspec.json @@ -1,6 +1,6 @@ { "name": "RNUserDefaults", - "version": "1.7.0", + "version": "1.8.1", "summary": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.", "description": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.", "license": "MIT", diff --git a/ios/Pods/Manifest.lock b/ios/Pods/Manifest.lock index 2fa005932..f5c448138 100644 --- a/ios/Pods/Manifest.lock +++ b/ios/Pods/Manifest.lock @@ -397,7 +397,7 @@ PODS: - React - RNScreens (2.0.0-alpha.3): - React - - RNUserDefaults (1.7.0): + - RNUserDefaults (1.8.1): - React - RNVectorIcons (6.6.0): - React @@ -786,7 +786,7 @@ SPEC CHECKSUMS: RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494 RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f - RNUserDefaults: af71a1cdf1c12baf8210bc741c65f5faba9826d6 + RNUserDefaults: c421fd97ad06b35c16608c5d0fe675db353f632d RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca diff --git a/ios/RocketChatRN/Info.plist b/ios/RocketChatRN/Info.plist index 9b18ce355..a4541cbfb 100644 --- a/ios/RocketChatRN/Info.plist +++ b/ios/RocketChatRN/Info.plist @@ -67,7 +67,7 @@ NSMicrophoneUsageDescription Use your microphone to record audio messages NSMotionUsageDescription - Allow $(PRODUCT_NAME) to access your device's accelerometer + Allow $(PRODUCT_NAME) to access your device's accelerometer NSPhotoLibraryAddUsageDescription Give $(PRODUCT_NAME) permission to save photos NSPhotoLibraryUsageDescription @@ -110,5 +110,7 @@ firefox brave + AppGroup + group.ios.chat.rocket diff --git a/ios/ShareRocketChatRN/Info.plist b/ios/ShareRocketChatRN/Info.plist index 1a75bed69..3e98094be 100644 --- a/ios/ShareRocketChatRN/Info.plist +++ b/ios/ShareRocketChatRN/Info.plist @@ -60,5 +60,7 @@ custom.ttf + AppGroup + group.ios.chat.rocket diff --git a/package.json b/package.json index 4a872b5b4..09818f0e5 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "rn-extensions-share": "^2.3.10", "rn-fetch-blob": "0.11.2", "rn-root-view": "^1.0.3", - "rn-user-defaults": "1.7.0", + "rn-user-defaults": "^1.8.1", "semver": "6.3.0", "snyk": "1.210.0", "strip-ansi": "5.2.0", diff --git a/patches/react-native+0.61.5.patch b/patches/react-native+0.61.5.patch index 400994539..328cdf232 100644 --- a/patches/react-native+0.61.5.patch +++ b/patches/react-native+0.61.5.patch @@ -1,8 +1,16 @@ diff --git a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm -index e72e943..ec0a0ba 100644 +index e72e943..ee0c7a1 100644 --- a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm +++ b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm -@@ -55,6 +55,59 @@ - (BOOL)canHandleRequest:(NSURLRequest *)request +@@ -10,6 +10,7 @@ + #import + + #import ++#import "RNUserDefaults.h" + + @interface RCTHTTPRequestHandler () + +@@ -55,6 +56,59 @@ - (BOOL)canHandleRequest:(NSURLRequest *)request return [schemes containsObject:request.URL.scheme.lowercaseString]; } @@ -62,14 +70,14 @@ index e72e943..ec0a0ba 100644 - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request withDelegate:(id)delegate { -@@ -171,4 +224,20 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp +@@ -171,4 +225,20 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp [delegate URLRequest:task didCompleteWithError:error]; } +-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler { + + NSString *host = challenge.protectionSpace.host; -+ NSDictionary *clientSSL = [[[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"] objectForKey:host]; ++ NSDictionary *clientSSL = [[RNUserDefaults getDefaultUser] objectForKey:host]; + + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + @@ -84,10 +92,19 @@ index e72e943..ec0a0ba 100644 + @end diff --git a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m -index a134d2e..a88c099 100644 +index a134d2e..1526d60 100644 --- a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m +++ b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m -@@ -481,6 +481,29 @@ - (void)didConnect +@@ -27,6 +27,8 @@ + #import + #import + ++#import "RNUserDefaults.h" ++ + typedef NS_ENUM(NSInteger, RCTSROpCode) { + RCTSROpCodeTextFrame = 0x1, + RCTSROpCodeBinaryFrame = 0x2, +@@ -481,6 +483,29 @@ - (void)didConnect [self _readHTTPHeader]; } @@ -117,12 +134,12 @@ index a134d2e..a88c099 100644 - (void)_initializeStreams; { assert(_url.port.unsignedIntValue <= UINT32_MAX); -@@ -518,6 +541,15 @@ - (void)_initializeStreams; +@@ -518,6 +543,15 @@ - (void)_initializeStreams; RCTLogInfo(@"SocketRocket: In debug mode. Allowing connection to any root cert"); #endif + // SSL Pinning -+ NSDictionary *clientSSL = [[[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"] objectForKey:host]; ++ NSDictionary *clientSSL = [[RNUserDefaults getDefaultUser] objectForKey:host]; + if (clientSSL != (id)[NSNull null]) { + NSString *path = [clientSSL objectForKey:@"path"]; + NSString *password = [clientSSL objectForKey:@"password"]; @@ -133,7 +150,7 @@ index a134d2e..a88c099 100644 [_outputStream setProperty:SSLOptions forKey:(__bridge id)kCFStreamPropertySSLSettings]; } -@@ -597,6 +629,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; +@@ -597,6 +631,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; } } diff --git a/patches/react-native-notifications+2.0.6.patch b/patches/react-native-notifications+2.0.6.patch index b531954b4..76440b62b 100644 --- a/patches/react-native-notifications+2.0.6.patch +++ b/patches/react-native-notifications+2.0.6.patch @@ -1,8 +1,16 @@ diff --git a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m -index edc4fd4..aeb5eaa 100644 +index edc4fd4..7cd77f6 100644 --- a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m +++ b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m -@@ -28,9 +28,92 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp +@@ -3,6 +3,7 @@ + #import "RNNotificationUtils.h" + #import "RCTConvert+RNNotifications.h" + #import "RNNotificationParser.h" ++#import "RNUserDefaults.h" + + @implementation RNNotificationEventHandler { + RNNotificationsStore* _store; +@@ -28,9 +29,91 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp [RNEventEmitter sendEvent:RNNotificationReceivedForeground body:[RNNotificationParser parseNotification:notification]]; } @@ -54,10 +62,9 @@ index edc4fd4..aeb5eaa 100644 + NSString *msg = [(UNTextInputNotificationResponse *)response userText]; + + // get credentials -+ NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"]; + NSString *TOKEN_KEY = @"reactnativemeteor_usertoken"; -+ NSString *userId = [userDefaults stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, [self serverURL:host]]]; -+ NSString *token = [userDefaults stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, userId]]; ++ NSString *userId = [[RNUserDefaults getDefaultUser] stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, [self serverURL:host]]]; ++ NSString *token = [[RNUserDefaults getDefaultUser] stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, userId]]; + + // background task - we need this because fetch doesn't work if app is closed/killed + UIApplication *app = [UIApplication sharedApplication]; diff --git a/yarn.lock b/yarn.lock index fd8a4f878..7791f26b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10379,10 +10379,10 @@ rn-root-view@^1.0.3: resolved "https://registry.yarnpkg.com/rn-root-view/-/rn-root-view-1.0.3.tgz#a2cddc717278cb2175fb29b7c006e407b7f0d0e2" integrity sha512-BIKm8hY5q8+pxK9B5ugYjqutoI9xn2JfxIZKWoaFmAl1bOIM4oXjwFQrRM1e6lFgzz99MN6Mf2dK3Alsywnvvw== -rn-user-defaults@1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/rn-user-defaults/-/rn-user-defaults-1.7.0.tgz#8d1b79657dec3977e8f8983814b8591821f77236" - integrity sha512-Qo6sIH8wldmQ0oOMMvljec4WOa/a1Up1pdatoXZGaPG1gl8OKgKH5HPKyddcABYtxPeBUTPVzCxP/6S6wPCqGQ== +rn-user-defaults@^1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/rn-user-defaults/-/rn-user-defaults-1.8.1.tgz#ccb8048f3ce43388ae40ac33eb063bfa93071702" + integrity sha512-pnUiB6Xn++5YGzSA1BKOsRAdz/GPkW3MViN5Yii6XGp5d6arcP4pOVIGmiFlOfxIFrHD3GU440WFnt5L7ogMSg== rsvp@^3.3.3: version "3.6.2"