Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ios/Classes/TiWebdialogAuthenticationSessionProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
* Please see the LICENSE included with this distribution for details.
*/

#import "TiProxy.h"
#import <TitaniumKit/TitaniumKit.h>
#import <AuthenticationServices/AuthenticationServices.h>

#if IS_IOS_13
@interface TiWebdialogAuthenticationSessionProxy : TiProxy <ASWebAuthenticationPresentationContextProviding>
#else
@interface TiWebdialogAuthenticationSessionProxy : TiProxy
#endif
{
id _authSession;
ASWebAuthenticationSession *_authSession;
}

#pragma mark Public API's
Expand Down
37 changes: 10 additions & 27 deletions ios/Classes/TiWebdialogAuthenticationSessionProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,23 @@
*/

#import "TiWebdialogAuthenticationSessionProxy.h"
#import "TiUtils.h"
#import <SafariServices/SafariServices.h>

@implementation TiWebdialogAuthenticationSessionProxy

- (id)authSession
- (ASWebAuthenticationSession *)authSession
{
if (_authSession == nil) {
NSString *url = [TiUtils stringValue:[self valueForKey:@"url"]];
NSString *scheme = [TiUtils stringValue:[self valueForKey:@"scheme"]];

if ([TiUtils isIOSVersionOrGreater:@"12.0"]) {
_authSession = [[ASWebAuthenticationSession alloc] initWithURL:[TiUtils toURL:url proxy:self]
callbackURLScheme:scheme
completionHandler:^(NSURL *_Nullable callbackURL, NSError *_Nullable error) {
[self fireEventWithCallbackUrl:callbackURL andError:error];
}];
#if IS_IOS_13
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
((ASWebAuthenticationSession *)_authSession).presentationContextProvider = self;
}
#endif
} else {
_authSession = [[SFAuthenticationSession alloc] initWithURL:[TiUtils toURL:url proxy:self]
callbackURLScheme:scheme
completionHandler:^(NSURL *callbackURL, NSError *error) {
[self fireEventWithCallbackUrl:callbackURL andError:error];
}];
}
_authSession = [[ASWebAuthenticationSession alloc] initWithURL:[TiUtils toURL:url proxy:self]
callbackURLScheme:scheme
completionHandler:^(NSURL *_Nullable callbackURL, NSError *_Nullable error) {
[self fireEventWithCallbackUrl:callbackURL andError:error];
}];

_authSession.presentationContextProvider = self;
}

return _authSession;
Expand Down Expand Up @@ -71,12 +59,7 @@ - (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuth

- (void)start:(id)unused
{
id session = [self authSession];
if ([session isKindOfClass:[SFAuthenticationSession class]]) {
[(SFAuthenticationSession *)session start];
} else if ([session isKindOfClass:[ASWebAuthenticationSession class]]) {
[(ASWebAuthenticationSession *)session start];
}
[[self authSession] start];
}

- (void)cancel:(id)unused
Expand All @@ -86,7 +69,7 @@ - (void)cancel:(id)unused

- (NSNumber *)isSupported:(id)unused
{
return NUMBOOL([TiUtils isIOSVersionOrGreater:@"11.0"]);
return @(YES);
}

@end
2 changes: 1 addition & 1 deletion ios/Classes/TiWebdialogModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Please see the LICENSE included with this distribution for details.
*/

#import "TiModule.h"
#import <TitaniumKit/TitaniumKit.h>
#import <SafariServices/SafariServices.h>

@interface TiWebdialogModule : TiModule <SFSafariViewControllerDelegate> {
Expand Down
25 changes: 6 additions & 19 deletions ios/Classes/TiWebdialogModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*/

#import "TiWebdialogModule.h"
#import "TiApp.h"
#import "TiBase.h"
#import "TiHost.h"
#import "TiUtils.h"

@implementation TiWebdialogModule

Expand Down Expand Up @@ -65,17 +61,12 @@ - (SFSafariViewController *)safariController:(NSString *)url withEntersReaderIfA
NSString *encodedURL = [url stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
NSURL *safariURL = [NSURL URLWithString:encodedURL];

if (@available(iOS 11.0, *)) {
SFSafariViewControllerConfiguration *config = [[SFSafariViewControllerConfiguration alloc] init];
config.entersReaderIfAvailable = entersReaderIfAvailable;
config.barCollapsingEnabled = barCollapsingEnabled;
SFSafariViewControllerConfiguration *config = [[SFSafariViewControllerConfiguration alloc] init];
config.entersReaderIfAvailable = entersReaderIfAvailable;
config.barCollapsingEnabled = barCollapsingEnabled;

_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
configuration:config];
} else {
_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
entersReaderIfAvailable:entersReaderIfAvailable];
}
_safariController = [[SFSafariViewController alloc] initWithURL:safariURL
configuration:config];

[_safariController setDelegate:self];
}
Expand Down Expand Up @@ -160,11 +151,7 @@ - (void)open:(id)args
}

if ([args objectForKey:@"dismissButtonStyle"]) {
if (@available(iOS 11.0, *)) {
[safari setDismissButtonStyle:[TiUtils intValue:@"dismissButtonStyle" properties:args def:SFSafariViewControllerDismissButtonStyleDone]];
} else {
NSLog(@"[ERROR] Ti.WebDialog: The dismissButtonStyle property is only available in iOS 11 and later");
}
[safari setDismissButtonStyle:[TiUtils intValue:@"dismissButtonStyle" properties:args def:SFSafariViewControllerDismissButtonStyleDone]];
}

[[TiApp app] showModalController:safari
Expand Down
9 changes: 5 additions & 4 deletions ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.0.2
version: 4.0.0
apiversion: 2
architectures: armv7 arm64 i386 x86_64
architectures: arm64 x86_64
description: titanium-web-dialog
author: Hans Knoechel
license: Apache 2.0
copyright: Copyright (c) 2017-present by Axway Appcelerator
mac: false
copyright: Copyright (c) 2017-present by TiDev

# these should not be edited
name: titanium-web-dialog
moduleid: ti.webdialog
guid: 1f19cce1-0ad7-4e25-ab3b-0666f54a0a49
platform: iphone
minsdk: 9.2.0
minsdk: 12.0.0
Loading