Skip to content

Commit 57d7eb1

Browse files
authored
Merge pull request #15 from cgoboncan-ebsi/master
fix(ios13): Fixing issue with changes to ASWebAuthenticationSession.
2 parents 6c7e6cf + 7b7c41b commit 57d7eb1

File tree

7 files changed

+69
-8
lines changed

7 files changed

+69
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ in case of vulnerabilities.
2222

2323
## [Unreleased]
2424

25+
## [2.0.1] - 2019-10-15
26+
### Fixed
27+
- **iOS:** Conform to the new iOS 13 API for ASWebAuthenticationSession. ASWebAuthenticationSession now requires a delegate that provides a display context for the authentication session. [#14](https://github.com/proyecto26/nativescript-inappbrowser/issues/14)
28+
2529
## [2.0.0] - 2019-07-27
2630
### Added
2731
- **Android:** Migrate to AndroidX by [@jdnichollsc](https://github.com/jdnichollsc) ([3e7ca9a](https://github.com/proyecto26/nativescript-inappbrowser/commit/3e7ca9a6f41f182a62b61435ef13c9c5fa043978)).

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/InAppBrowser.ios.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const getTransitionStyle = function (styleKey: string) {
5656
return styles[styleKey] || UIModalTransitionStyle.CoverVertical;
5757
};
5858

59-
const InAppBrowser = (<any>NSObject).extend({
59+
const classMembers = {
6060
redirectResolve: null,
6161
redirectReject: null,
6262
authSession: <SFAuthenticationSession | ASWebAuthenticationSession> null,
@@ -158,6 +158,9 @@ const InAppBrowser = (<any>NSObject).extend({
158158
self.flowDidFinish();
159159
}
160160
);
161+
if(ios.MajorVersion >= 13) {
162+
self.authSession.presentationContextProvider = self;
163+
}
161164
self.authSession.start();
162165
});
163166
}
@@ -185,6 +188,9 @@ const InAppBrowser = (<any>NSObject).extend({
185188
this.close();
186189
}
187190
},
191+
presentationAnchorForWebAuthenticationSession: function (session: ASWebAuthenticationSession): UIWindow {
192+
return UIApplication.sharedApplication.keyWindow;
193+
},
188194
dismissWithoutAnimation(controller: SFSafariViewController): void {
189195
const transition = CATransition.animation();
190196
transition.duration = 0.0;
@@ -229,8 +235,18 @@ const InAppBrowser = (<any>NSObject).extend({
229235
this.redirectReject = reject;
230236
return true;
231237
}
232-
}, {
233-
protocols: [SFSafariViewControllerDelegate]
234-
});
238+
};
239+
240+
const nativeSignatures =
241+
ios.MajorVersion >= 13
242+
? {
243+
protocols: [
244+
SFSafariViewControllerDelegate,
245+
ASWebAuthenticationPresentationContextProviding
246+
]
247+
}
248+
: { protocols: [SFSafariViewControllerDelegate] };
249+
250+
const InAppBrowser = (<any>NSObject).extend(classMembers, nativeSignatures);
235251

236-
export default InAppBrowser.new();
252+
export default InAppBrowser.new();

src/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-inappbrowser",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "InAppBrowser for NativeScript",
55
"main": "InAppBrowser",
66
"typings": "index.d.ts",

src/references.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
22
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
3-
/// <reference path="./types/android.d.ts" />
3+
/// <reference path="./types/android.d.ts" />
4+
/// <reference path="./types/ios.d.ts" />
5+

src/types/ios.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
interface ASWebAuthenticationPresentationContextProviding
2+
extends NSObjectProtocol {
3+
presentationAnchorForWebAuthenticationSession(
4+
session: ASWebAuthenticationSession
5+
): UIWindow;
6+
}
7+
8+
declare var ASWebAuthenticationPresentationContextProviding: {
9+
prototype: ASWebAuthenticationPresentationContextProviding;
10+
};
11+
12+
declare class ASWebAuthenticationSession extends NSObject {
13+
static alloc(): ASWebAuthenticationSession; // inherited from NSObject
14+
15+
static new(): ASWebAuthenticationSession; // inherited from NSObject
16+
17+
prefersEphemeralWebBrowserSession: boolean;
18+
19+
presentationContextProvider: ASWebAuthenticationPresentationContextProviding;
20+
21+
constructor(o: {
22+
URL: NSURL;
23+
callbackURLScheme: string;
24+
completionHandler: (p1: NSURL, p2: NSError) => void;
25+
});
26+
27+
cancel(): void;
28+
29+
initWithURLCallbackURLSchemeCompletionHandler(
30+
URL: NSURL,
31+
callbackURLScheme: string,
32+
completionHandler: (p1: NSURL, p2: NSError) => void
33+
): this;
34+
35+
start(): boolean;
36+
}

0 commit comments

Comments
 (0)