feat(ios): Support custom scheme event for iOS#1112
Conversation
|
This replicates #274 for the WKWebView |
| return NO; | ||
| } | ||
|
|
||
| - (BOOL)isAllowedScheme:(NSString*)scheme |
There was a problem hiding this comment.
Please keep the code formatting, there should be a space between the type and pointer asterisk:
- (BOOL)isAllowedScheme:(NSString *)schemeThere was a problem hiding this comment.
I fixed it following the other lines.
|
|
||
| - (BOOL)isAllowedScheme:(NSString*)scheme | ||
| { | ||
| NSString* allowedSchemesPreference = [self.commandDelegate.settings objectForKey:@"AllowedSchemes"]; |
There was a problem hiding this comment.
Keep the formatting:
NSString *allowedSchemesPreferenceUse the _settings property to get a setting:
[_settings cordovaSettingForKey:@"AllowedSchemes"]There was a problem hiding this comment.
I fixed it following the other lines.
| // Preference missing. | ||
| return NO; | ||
| } | ||
| for (NSString* allowedScheme in [allowedSchemesPreference componentsSeparatedByString:@","]) { |
There was a problem hiding this comment.
Keep the formatting:
NSString *allowedSchemeThere was a problem hiding this comment.
I fixed it following the other lines.
| [theWebView stopLoading]; | ||
| [self openInSystem:url]; | ||
| shouldStart = NO; | ||
| } else if ((self.callbackId != nil) && ![[ url scheme] isEqualToString:@"http"] && ![[ url scheme] isEqualToString:@"https"] && [self isAllowedScheme:[url scheme]]) { |
There was a problem hiding this comment.
- You don't need braces for
(self.callbackId != nil)just writeself.callbackId != nil schemeis a property ofurl, writeurl.schemeinstead of[ url scheme]- Add documentation to the condition, what's happening here
There was a problem hiding this comment.
- Add documentation to the condition, what's happening here
I added comment and clarify the condition.
| } 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]}]; |
There was a problem hiding this comment.
absoluteStringis a property ofurl, writeurl.absoluteStringinstead of[url absoluteString]
| // Send a customscheme event. | ||
| CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK | ||
| messageAsDictionary:@{@"type":@"customscheme", @"url":[url absoluteString]}]; | ||
| [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]]; |
There was a problem hiding this comment.
- Write here
pluginResult.keepCallback = [NSNumber numberWithBool:YES];
| return NO; | ||
| } | ||
|
|
||
| - (BOOL)isAllowedScheme:(NSString*)scheme |
|
@GitToTheHub I have a few suggestions.:
|
I think above choice is better so that I fixed following this policy for now. |
|
Can you make up to date with the master? |
ac7b046 to
da984b0
Compare
da984b0 to
80b38ed
Compare
I updated my branch. |
|
@GitToTheHub I think the point is who should check scheme. I think |
|
You are right, |
Platforms affected
iOS
Motivation and Context
Implements CB-14187, which adds support for the
AllowedSchemespreference andcustomschemeevent for iOS. #274 is same context and I referred but the PR is not updated for years.Description
Add support for the
AllowedSchemespreference andcustomschemeevent for iOS.Testing
Tested with iOS simulator.
Checklist
(platform)if this change only applies to one platform (e.g.(android))