From 1f783d5743ecb1f1bf81a8d44e8d185bf325a7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastiaan?= Date: Sun, 25 Oct 2020 18:19:09 +0100 Subject: [PATCH] Finish OAuth for iOS --- ios/ThaliApp.xcodeproj/project.pbxproj | 10 ++++------ ios/ThaliApp/AppDelegate.h | 5 ++++- ios/ThaliApp/AppDelegate.m | 13 +++++++++++-- ios/ThaliApp/Info.plist | 11 +++++++++++ ...ppRelease.entitlements => ThaliApp.entitlements} | 0 ios/ThaliApp/ThaliAppDebug.entitlements | 8 -------- 6 files changed, 30 insertions(+), 17 deletions(-) rename ios/ThaliApp/{ThaliAppRelease.entitlements => ThaliApp.entitlements} (100%) delete mode 100644 ios/ThaliApp/ThaliAppDebug.entitlements diff --git a/ios/ThaliApp.xcodeproj/project.pbxproj b/ios/ThaliApp.xcodeproj/project.pbxproj index 0373017..b588ae0 100644 --- a/ios/ThaliApp.xcodeproj/project.pbxproj +++ b/ios/ThaliApp.xcodeproj/project.pbxproj @@ -56,9 +56,8 @@ 2D02E4901E0B4A5D006451C7 /* ThaliApp-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ThaliApp-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2F1107B2451978230CDD0198 /* Pods-ThaliApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ThaliApp.release.xcconfig"; path = "Target Support Files/Pods-ThaliApp/Pods-ThaliApp.release.xcconfig"; sourceTree = ""; }; 327170882530FCBE00742C9A /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LaunchScreen.xib; path = ThaliApp/LaunchScreen.xib; sourceTree = ""; }; - 3296B7552530F1CE00A5FDF7 /* ThaliAppDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ThaliAppDebug.entitlements; path = ThaliApp/ThaliAppDebug.entitlements; sourceTree = ""; }; + 329872062545E40A00289767 /* ThaliApp.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; name = ThaliApp.entitlements; path = ThaliApp/ThaliApp.entitlements; sourceTree = ""; }; 469C2F6B25207AD000F8B3BE /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - 469C302C2520999900F8B3BE /* ThaliAppRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ThaliAppRelease.entitlements; path = ThaliApp/ThaliAppRelease.entitlements; sourceTree = ""; }; 521300258F0CDF8B3D54C220 /* Pods-ThaliApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ThaliApp.debug.xcconfig"; path = "Target Support Files/Pods-ThaliApp/Pods-ThaliApp.debug.xcconfig"; sourceTree = ""; }; C2D9C10259285A7469D1F115 /* libPods-ThaliApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ThaliApp.a"; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; @@ -119,9 +118,8 @@ 13B07FAE1A68108700A75B9A /* ThaliApp */ = { isa = PBXGroup; children = ( + 329872062545E40A00289767 /* ThaliApp.entitlements */, 327170882530FCBE00742C9A /* LaunchScreen.xib */, - 3296B7552530F1CE00A5FDF7 /* ThaliAppDebug.entitlements */, - 469C302C2520999900F8B3BE /* ThaliAppRelease.entitlements */, 469C2F6B25207AD000F8B3BE /* GoogleService-Info.plist */, 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, @@ -641,7 +639,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-Dev"; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = ThaliApp/ThaliAppDebug.entitlements; + CODE_SIGN_ENTITLEMENTS = ThaliApp/ThaliApp.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; @@ -684,7 +682,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = ThaliApp/ThaliAppRelease.entitlements; + CODE_SIGN_ENTITLEMENTS = ThaliApp/ThaliApp.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; diff --git a/ios/ThaliApp/AppDelegate.h b/ios/ThaliApp/AppDelegate.h index ef1de86..0f69b1e 100644 --- a/ios/ThaliApp/AppDelegate.h +++ b/ios/ThaliApp/AppDelegate.h @@ -1,8 +1,11 @@ #import #import +#import "RNAppAuthAuthorizationFlowManager.h" -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder @property (nonatomic, strong) UIWindow *window; +@property(nonatomic, weak)idauthorizationFlowManagerDelegate; + @end diff --git a/ios/ThaliApp/AppDelegate.m b/ios/ThaliApp/AppDelegate.m index 3e7d4af..c5e131d 100644 --- a/ios/ThaliApp/AppDelegate.m +++ b/ios/ThaliApp/AppDelegate.m @@ -55,14 +55,23 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + if (self.authorizationFlowManagerDelegate) { + if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) { + return YES; + } + } return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html). -- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity - restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler +- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler { + if (self.authorizationFlowManagerDelegate) { + if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:userActivity.webpageURL]) { + return YES; + } + } return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; diff --git a/ios/ThaliApp/Info.plist b/ios/ThaliApp/Info.plist index d4e93b2..147930f 100644 --- a/ios/ThaliApp/Info.plist +++ b/ios/ThaliApp/Info.plist @@ -22,6 +22,17 @@ ???? CFBundleVersion $(CURRENT_PROJECT_VERSION) + CFBundleURLTypes + + + CFBundleURLName + com.thaliapp + CFBundleURLSchemes + + nu.thalia + + + LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/ios/ThaliApp/ThaliAppRelease.entitlements b/ios/ThaliApp/ThaliApp.entitlements similarity index 100% rename from ios/ThaliApp/ThaliAppRelease.entitlements rename to ios/ThaliApp/ThaliApp.entitlements diff --git a/ios/ThaliApp/ThaliAppDebug.entitlements b/ios/ThaliApp/ThaliAppDebug.entitlements deleted file mode 100644 index 903def2..0000000 --- a/ios/ThaliApp/ThaliAppDebug.entitlements +++ /dev/null @@ -1,8 +0,0 @@ - - - - - aps-environment - development - -