GitToTheHub commented on code in PR #1112:
URL:
https://github.com/apache/cordova-plugin-inappbrowser/pull/1112#discussion_r2779909766
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -483,6 +498,15 @@ - (void)webView:(WKWebView *)theWebView
decidePolicyForNavigationAction:(WKNavig
if ([allowedSchemes containsObject:[url scheme]]) {
[theWebView stopLoading];
[self openInSystem:url];
+ shouldStart = NO;
+ } else if ((self.callbackId != nil) && ![[ url scheme]
isEqualToString:@"http"] && ![[ url scheme] isEqualToString:@"https"] && [self
isAllowedScheme:[url scheme]]) {
+ // Send a customscheme event.
+ CDVPluginResult* pluginResult = [CDVPluginResult
resultWithStatus:CDVCommandStatus_OK
+
messageAsDictionary:@{@"type":@"customscheme", @"url":[url absoluteString]}];
Review Comment:
- `absoluteString` is a property of `url`, write `url.absoluteString`
instead of `[url absoluteString]`
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -431,6 +431,21 @@ - (BOOL)isValidCallbackId:(NSString *)callbackId
return NO;
}
+- (BOOL)isAllowedScheme:(NSString*)scheme
+{
+ NSString* allowedSchemesPreference = [self.commandDelegate.settings
objectForKey:@"AllowedSchemes"];
Review Comment:
Keep the formatting:
```objc
NSString *allowedSchemesPreference
```
Use the `_settings` property to get a setting:
```objc
[_settings cordovaSettingForKey:@"AllowedSchemes"]
```
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -431,6 +431,21 @@ - (BOOL)isValidCallbackId:(NSString *)callbackId
return NO;
}
+- (BOOL)isAllowedScheme:(NSString*)scheme
+{
+ NSString* allowedSchemesPreference = [self.commandDelegate.settings
objectForKey:@"AllowedSchemes"];
+ if (allowedSchemesPreference == nil || [allowedSchemesPreference
isEqualToString:@""]) {
+ // Preference missing.
+ return NO;
+ }
+ for (NSString* allowedScheme in [allowedSchemesPreference
componentsSeparatedByString:@","]) {
Review Comment:
Keep the formatting:
```objc
NSString *allowedScheme
```
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -431,6 +431,21 @@ - (BOOL)isValidCallbackId:(NSString *)callbackId
return NO;
}
+- (BOOL)isAllowedScheme:(NSString*)scheme
Review Comment:
Please keep the code formatting, there should be a space between the type
and pointer asterisk:
```objc
- (BOOL)isAllowedScheme:(NSString *)scheme
```
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -483,6 +498,15 @@ - (void)webView:(WKWebView *)theWebView
decidePolicyForNavigationAction:(WKNavig
if ([allowedSchemes containsObject:[url scheme]]) {
[theWebView stopLoading];
[self openInSystem:url];
+ shouldStart = NO;
+ } else if ((self.callbackId != nil) && ![[ url scheme]
isEqualToString:@"http"] && ![[ url scheme] isEqualToString:@"https"] && [self
isAllowedScheme:[url scheme]]) {
+ // Send a customscheme event.
+ CDVPluginResult* pluginResult = [CDVPluginResult
resultWithStatus:CDVCommandStatus_OK
+
messageAsDictionary:@{@"type":@"customscheme", @"url":[url absoluteString]}];
+ [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
Review Comment:
- Write here `pluginResult.keepCallback = [NSNumber numberWithBool:YES];`
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -483,6 +498,15 @@ - (void)webView:(WKWebView *)theWebView
decidePolicyForNavigationAction:(WKNavig
if ([allowedSchemes containsObject:[url scheme]]) {
[theWebView stopLoading];
[self openInSystem:url];
+ shouldStart = NO;
+ } else if ((self.callbackId != nil) && ![[ url scheme]
isEqualToString:@"http"] && ![[ url scheme] isEqualToString:@"https"] && [self
isAllowedScheme:[url scheme]]) {
Review Comment:
- You don't need braces for `(self.callbackId != nil)` just write
`self.callbackId != nil`
- `scheme` is a property of `url`, write `url.scheme` instead of `[ url
scheme]`
- Add documentation to the condition, what's happening here
##########
src/ios/CDVWKInAppBrowser.m:
##########
@@ -431,6 +431,21 @@ - (BOOL)isValidCallbackId:(NSString *)callbackId
return NO;
}
+- (BOOL)isAllowedScheme:(NSString*)scheme
Review Comment:
Document this method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]