Skip to content

Commit

Permalink
Merge pull request #455 from Adyen/expo-router
Browse files Browse the repository at this point in the history
Improve expo-router compatibility
  • Loading branch information
descorp authored May 31, 2024
2 parents e757649 + d8bd3eb commit fe5ef7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ In case you are using `RCTLinkingManager` or other deep-linking techniques, plac
```objc
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [ADYRedirectComponent applicationDidOpenURL:url] || [RCTLinkingManager application:application openURL:url options:options];
return [ADYRedirectComponent applicationDidOpenURL:url] || [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
}
```
Expand All @@ -110,11 +110,12 @@ For Universal Link support, use:
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = [userActivity webpageURL];
if (![url isEqual:[NSNull null]]) {
return [ADYRedirectComponent applicationDidOpenURL:url];
if (![url isEqual:[NSNull null]] && [ADYRedirectComponent applicationDidOpenURL:url]) {
return YES;
}
}
return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}
```
Expand Down
11 changes: 6 additions & 5 deletions plugin/src/setApplicationContinueUserActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export function setApplicationContinueUserActivity(contents: string): string {
'- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {\n' +
' if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {\n' +
' NSURL *url = [userActivity webpageURL];\n' +
' if (![url isEqual:[NSNull null]]) {\n' +
' return [ADYRedirectComponent applicationDidOpenURL:url];\n' +
' if (![url isEqual:[NSNull null]] && [ADYRedirectComponent applicationDidOpenURL:url]) {\n' +
' return YES;\n' +
' }\n' +
' }\n'
);
Expand All @@ -21,11 +21,12 @@ export function setApplicationContinueUserActivity(contents: string): string {
'- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {\n' +
' if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {\n' +
' NSURL *url = [userActivity webpageURL];\n' +
' if (![url isEqual:[NSNull null]]) {\n' +
' return [ADYRedirectComponent applicationDidOpenURL:url];\n' +
' if (![url isEqual:[NSNull null]] && [ADYRedirectComponent applicationDidOpenURL:url]) {\n' +
' return YES;\n' +
' }\n' +
' }\n' +
' return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler];\n' +
' BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];\n' +
' return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;\n' +
'}\n' +
'@end'
);
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/setApplicationOpenUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function setApplicationOpenUrl(contents: string): string {
'@end',
`\n` +
`- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {\n` +
` return [ADYRedirectComponent applicationDidOpenURL:url];\n` +
` return [ADYRedirectComponent applicationDidOpenURL:url] || [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];\n` +
`}\n` +
'@end'
);
Expand Down

0 comments on commit fe5ef7e

Please sign in to comment.