Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions app/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions ios/RocketChatRN/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,7 @@
<string>firefox</string>
<string>brave</string>
</array>
<key>SuiteName</key>
djorkaeffalexandre marked this conversation as resolved.
Show resolved Hide resolved
<string>group.ios.chat.rocket</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ios/ShareRocketChatRN/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@
<array>
<string>custom.ttf</string>
</array>
<key>SuiteName</key>
<string>group.ios.chat.rocket</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0",
"semver": "6.3.0",
"snyk": "1.210.0",
"strip-ansi": "5.2.0",
Expand Down
35 changes: 26 additions & 9 deletions patches/react-native+0.61.5.patch
Original file line number Diff line number Diff line change
@@ -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 <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];
}

Expand Down Expand Up @@ -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];
+
Expand All @@ -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];
}

Expand Down Expand Up @@ -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"];
Expand All @@ -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;
}
}

Expand Down
17 changes: 12 additions & 5 deletions patches/react-native-notifications+2.0.6.patch
Original file line number Diff line number Diff line change
@@ -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]];
}

Expand Down Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/rn-user-defaults/-/rn-user-defaults-1.8.0.tgz#10b9e72266de6fdacab9f47b847ed8d9a3131c3b"
integrity sha512-9xqKtV7gr5shqB/eqmFiQ3BffGhT6eqXoVAXcQnmKDG9s0j0GRysLWLXRww/qiUS8eJYzRtJR3YvxKz71nkWLw==

rsvp@^3.3.3:
version "3.6.2"
Expand Down