Unverified Commit 1a355116 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

[IMPROVEMENT] Create App Group property on Info.plist (#1858)


Co-authored-by: default avatarDiego Mello <diegolmello@gmail.com>
parent 9bea72fa
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
{
"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",
......
......@@ -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
......
......@@ -67,7 +67,7 @@
<key>NSMicrophoneUsageDescription</key>
<string>Use your microphone to record audio messages</string>
<key>NSMotionUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your device's accelerometer</string>
<string>Allow $(PRODUCT_NAME) to access your device&apos;s accelerometer</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Give $(PRODUCT_NAME) permission to save photos</string>
<key>NSPhotoLibraryUsageDescription</key>
......@@ -110,5 +110,7 @@
<string>firefox</string>
<string>brave</string>
</array>
<key>AppGroup</key>
<string>group.ios.chat.rocket</string>
</dict>
</plist>
......@@ -60,5 +60,7 @@
<array>
<string>custom.ttf</string>
</array>
<key>AppGroup</key>
<string>group.ios.chat.rocket</string>
</dict>
</plist>
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 <mutex>
#import <React/RCTNetworking.h>
+#import "RNUserDefaults.h"
@interface RCTHTTPRequestHandler () <NSURLSessionDataDelegate>
@@ -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<RCTURLRequestDelegate>)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 <React/RCTAssert.h>
#import <React/RCTLog.h>
+#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/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];
......
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment