This repository was archived by the owner on May 20, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-20
lines changed
Expand file tree Collapse file tree 3 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,10 @@ static void InitializeFlipper(UIApplication *application) {
2828@implementation AppDelegate
2929
3030- (BOOL )application : (UIApplication *)application openURL : (NSURL *)url options : (NSDictionary <UIApplicationOpenURLOptionsKey,id> *)options {
31- return [MSALPublicClientApplication handleMSALResponse: url sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey]] || [RCTLinkingManager application: application openURL: url options: options];
31+ if ([MSALPublicClientApplication handleMSALResponse: url sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey]]) {
32+ return true ;
33+ }
34+ return [RCTLinkingManager application: application openURL: url options: options];
3235}
3336
3437- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions
Original file line number Diff line number Diff line change @@ -38,16 +38,16 @@ function setAppDelegate(appDelegate) {
3838 const [ firstLine , ...restOfLines ] = appDelegate . split ( '\n' ) ;
3939 appDelegate = firstLine + '\n\n#import <MSAL/MSAL.h>\n' + restOfLines . join ( '\n' ) ;
4040 }
41- const linkingMethod = `- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
42- return [MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]] || [RCTLinkingManager application:application openURL:url options:options];
43- }` ;
44- const linkingMethodRegex = / - \( B O O L \) a p p l i c a t i o n : \( U I A p p l i c a t i o n \* \) a p p l i c a t i o n \s + o p e n U R L : \( N S U R L \* \) u r l \s + o p t i o n s : \( N S D i c t i o n a r y < U I A p p l i c a t i o n O p e n U R L O p t i o n s K e y , i d > \* \) o p t i o n s \s * { .+ ?} / s;
45- if ( linkingMethodRegex . test ( appDelegate ) ) {
46- appDelegate = appDelegate . replace ( linkingMethodRegex , linkingMethod ) ;
47- }
48- else {
49- appDelegate = appDelegate . replace ( '@implementation AppDelegate' , `@implementation AppDelegate\n\n${ linkingMethod } ` ) ;
41+ const msalHandleResponseMethod = '[MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]]' ;
42+ if ( appDelegate . includes ( msalHandleResponseMethod ) ) {
43+ return appDelegate ;
5044 }
45+ const linkingMethodReturn = 'return [RCTLinkingManager application:application openURL:url options:options];' ;
46+ const newReturn = `if ([MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]]) {
47+ return true;
48+ }
49+ ${ linkingMethodReturn } ` ;
50+ appDelegate = appDelegate . replace ( linkingMethodReturn , newReturn ) ;
5151 return appDelegate ;
5252}
5353const withIosReactNativeMSAL = ( config ) => {
Original file line number Diff line number Diff line change @@ -40,17 +40,19 @@ function setAppDelegate(appDelegate: string) {
4040 appDelegate = firstLine + '\n\n#import <MSAL/MSAL.h>\n' + restOfLines . join ( '\n' ) ;
4141 }
4242
43- const linkingMethod = `- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
44- return [MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]] || [RCTLinkingManager application:application openURL:url options:options] ;
45- }` ;
46- const linkingMethodRegex =
47- / - \( B O O L \) a p p l i c a t i o n : \( U I A p p l i c a t i o n \* \) a p p l i c a t i o n \s + o p e n U R L : \( N S U R L \* \) u r l \s + o p t i o n s : \( N S D i c t i o n a r y < U I A p p l i c a t i o n O p e n U R L O p t i o n s K e y , i d > \* \) o p t i o n s \s * { . + ? } / s ;
48-
49- if ( linkingMethodRegex . test ( appDelegate ) ) {
50- appDelegate = appDelegate . replace ( linkingMethodRegex , linkingMethod ) ;
51- } else {
52- appDelegate = appDelegate . replace ( '@implementation AppDelegate' , `@implementation AppDelegate\n\n ${ linkingMethod } ` ) ;
43+ const msalHandleResponseMethod =
44+ ' [MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]]' ;
45+
46+ if ( appDelegate . includes ( msalHandleResponseMethod ) ) {
47+ return appDelegate ;
48+ }
49+
50+ const linkingMethodReturn = 'return [RCTLinkingManager application:application openURL:url options:options];' ;
51+ const newReturn = `if ([MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]]) {
52+ return true ;
5353 }
54+ ${ linkingMethodReturn } ` ;
55+ appDelegate = appDelegate . replace ( linkingMethodReturn , newReturn ) ;
5456 return appDelegate ;
5557}
5658
You can’t perform that action at this time.
0 commit comments