Skip to content

Commit 8e9b20c

Browse files
committed
Merge branch 'master' into develop
2 parents a8f8945 + ad9c6af commit 8e9b20c

34 files changed

+7701
-7833
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ in case of vulnerabilities.
2222

2323
## [Unreleased]
2424

25+
## [2.3.0] - 2020-04-08
26+
### Added
27+
- Added `ephemeralWebSession` option to supports `ephemeralWebBrowserSession` on iOS 13.
28+
- Fix issue loading initial url from Android resume event for authentication purposes.
29+
2530
## [2.2.0] - 2019-11-14
2631
### Added
2732
- Validate if the **type** of the auth result is different to `cancel` before to check the url of the last redirection from **Android**.
@@ -60,7 +65,8 @@ in case of vulnerabilities.
6065
- Methods to open and close external urls to authenticate the user **(openAuth, closeAuth)** using deep linking.
6166
- `isAvailable` method to detect if the device supports the plugin.
6267

63-
[Unreleased]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.2.0...HEAD
68+
[Unreleased]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.3.0...HEAD
69+
[2.3.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.2.0...v2.3.0
6470
[2.2.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.1.1...v2.2.0
6571
[2.1.1]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.1.0...v2.1.1
6672
[2.1.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.0.0...v2.1.0

README.md

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
</p>
3030

3131
<h1 align="center">InAppBrowser for NativeScript</h1>
32+
<h3 align="center">Provides access to the system's web browser and supports handling redirects</h3>
3233
<h4 align="center"><a href="https://developer.chrome.com/multidevice/android/customtabs#whatarethey">Chrome Custom Tabs</a> for Android & <a href="https://developer.apple.com/documentation/safariservices">SafariServices</a>/<a href="https://developer.apple.com/documentation/authenticationservices">AuthenticationServices</a> for iOS.</h4>
3334

3435
<p align="center">
@@ -66,6 +67,7 @@ Property | Description
6667
`modalTransitionStyle` (String) | The transition style to use when presenting the view controller. [`coverVertical`/`flipHorizontal`/`crossDissolve`/`partialCurl`]
6768
`modalEnabled` (Boolean) | Present the **SafariViewController** modally or as push instead. [`true`/`false`]
6869
`enableBarCollapsing` (Boolean) | Determines whether the browser's tool bars will collapse or not. [`true`/`false`]
70+
`ephemeralWebSession` (Boolean) | Prevent re-use cookies of previous session (openAuth only) [`true`/`false`]
6971

7072
### Android Options
7173
Property | Description
@@ -142,15 +144,100 @@ import InAppBrowser from 'nativescript-inappbrowser'
142144
...
143145
```
144146

145-
## Credits 👍
146-
* **React Native InAppBrowser:** [InAppBrowser for React Native](https://github.com/proyecto26/react-native-inappbrowser)
147+
### Authentication Flow using Deep Linking
148+
149+
In order to redirect back to your application from a web browser, you must specify a unique URI to your app. To do this,
150+
define your app scheme and replace `my-scheme` and `my-host` with your info.
151+
152+
- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/Android/src/main/AndroidManifest.xml#L41)**
153+
```
154+
<intent-filter>
155+
<action android:name="android.intent.action.VIEW" />
156+
<category android:name="android.intent.category.DEFAULT" />
157+
<category android:name="android.intent.category.BROWSABLE" />
158+
<data android:scheme="my-scheme" android:host="my-host" android:pathPrefix="" />
159+
</intent-filter>
160+
```
161+
162+
- Enable deep linking (iOS) - **[Info.plist](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/iOS/Info.plist#L21)**
163+
```
164+
<key>CFBundleURLTypes</key>
165+
<array>
166+
<dict>
167+
<key>CFBundleTypeRole</key>
168+
<string>Editor</string>
169+
<key>CFBundleURLName</key>
170+
<string>my-scheme</string>
171+
<key>CFBundleURLSchemes</key>
172+
<array>
173+
<string>my-scheme</string>
174+
</array>
175+
</dict>
176+
</array>
177+
```
178+
179+
- utilities.ts
180+
```javascript
181+
import { android } from "tns-core-modules/application";
182+
export const getDeepLink = (path = "") => {
183+
const scheme = 'my-scheme';
184+
const prefix = android ? `${scheme}://my-host/` : `${scheme}://`;
185+
return prefix + path;
186+
}
187+
```
188+
189+
- home-page.ts
190+
```javascript
191+
import { openUrl } from 'tns-core-modules/utils/utils';
192+
import InAppBrowser from 'nativescript-inappbrowser';
193+
import { getDeepLink } from './utilities';
194+
...
195+
async onLogin() {
196+
const deepLink = getDeepLink("callback")
197+
const url = `https://my-auth-login-page.com?redirect_uri=${deepLink}`
198+
try {
199+
if (await InAppBrowser.isAvailable()) {
200+
InAppBrowser.openAuth(url, deepLink, {
201+
// iOS Properties
202+
ephemeralWebSession: false,
203+
// Android Properties
204+
showTitle: false,
205+
enableUrlBarHiding: true,
206+
enableDefaultShare: false
207+
}).then((response) => {
208+
if (
209+
response.type === 'success' &&
210+
response.url
211+
) {
212+
openUrl(response.url)
213+
}
214+
})
215+
} else openUrl(url)
216+
} catch (error) {
217+
openUrl(url)
218+
}
219+
}
220+
...
221+
```
222+
223+
### Authentication
224+
225+
Using in-app browser tabs (like SFAuthenticationSession/ASWebAuthenticationSession and Android Custom Tabs) where available. Embedded user-agents, known as web-views (like UIWebView and WKWebView), are explicitly not supported due to the usability and security reasons documented in [Section 8.12 of RFC 8252](https://tools.ietf.org/html/rfc8252#section-8.12).
147226

148227
## Contributors ✨
149-
Thanks goes to these wonderful people:
150-
<!-- CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
228+
Please do contribute! Issues and pull requests are welcome.
229+
230+
### Code Contributors
231+
232+
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
233+
234+
[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/0)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/0)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/1)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/1)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/2)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/2)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/3)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/3)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/4)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/4)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/5)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/5)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/6)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/6)[![](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/images/7)](https://sourcerer.io/fame/jdnichollsc/proyecto26/nativescript-inappbrowser/links/7)
235+
236+
### Collaborators
237+
<!-- COLLABORATORS-LIST:START - Do not remove or modify this section -->
151238
| [<img alt="jdnichollsc" src="https://avatars3.githubusercontent.com/u/2154886?v=3" width="100" /><br /><sub><b>Juan Nicholls</b></sub>](https://github.com/jdnichollsc)<br />[](mailto:jdnichollsc@hotmail.com) | [<img alt="NathanaelA" src="https://avatars3.githubusercontent.com/u/850871?v=3" width="100" /><br /><sub><b>Nathanael Anderson</b></sub>](https://github.com/NathanaelA)<br />[](mailto:nathan@master-technology.com) |
152239
| :---: | :---: |
153-
<!-- CONTRIBUTORS-LIST:END -->
240+
<!-- COLLABORATORS-LIST:END -->
154241

155242
### Financial Contributors
156243

@@ -175,10 +262,18 @@ Support this project with your organization. Your logo will show up here with a
175262
<a href="https://opencollective.com/proyecto26/organization/8/website"><img src="https://opencollective.com/proyecto26/organization/8/avatar.svg"></a>
176263
<a href="https://opencollective.com/proyecto26/organization/9/website"><img src="https://opencollective.com/proyecto26/organization/9/avatar.svg"></a>
177264

265+
## Credits 👍
266+
* **React Native InAppBrowser:** [InAppBrowser for React Native](https://github.com/proyecto26/react-native-inappbrowser)
267+
178268
## Supporting 🍻
179269
I believe in Unicorns 🦄
180270
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.
181-
[Professionally supported nativescript-inappbrowser is coming soon](https://tidelift.com/subscription/pkg/npm-nativescript-inappbrowser?utm_source=npm-nativescript-inappbrowser&utm_medium=referral&utm_campaign=readme)
271+
272+
## Enterprise 💼
273+
274+
Available as part of the Tidelift Subscription.
275+
276+
The maintainers of InAppBrowser for NativeScript and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-nativescript-inappbrowser?utm_source=npm-nativescript-inappbrowser&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
182277

183278
## Security contact information 🚨
184279
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shareInterpolator="false" >
4+
<translate android:duration="500" android:fromXDelta="-100%" android:toXDelta="0%"/>
5+
<alpha android:duration="500" android:fromAlpha="0.0" android:toAlpha="1.0" />
6+
</set>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shareInterpolator="false" >
4+
<translate android:duration="500" android:fromXDelta="100%" android:toXDelta="0%" />
5+
<alpha android:duration="500" android:fromAlpha="0.0" android:toAlpha="1.0" />
6+
</set>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shareInterpolator="false" >
4+
<translate android:duration="500" android:fromXDelta="0%" android:toXDelta="-100%"/>
5+
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.0" />
6+
</set>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shareInterpolator="false" >
4+
<translate android:duration="500" android:fromXDelta="0%" android:toXDelta="100%"/>
5+
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.0" />
6+
</set>

demo/app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In many cases you may want to use the NativeScript core theme instead
99
of writing your own CSS rules. For a full list of class names in the theme
1010
refer to http://docs.nativescript.org/ui/theme.
1111
*/
12-
@import '~nativescript-theme-core/css/core.light.css';
12+
@import '~nativescript-theme-core/css/core.css';
1313

1414
TextField {
1515
border-width: 1;

demo/app/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ You can use this file to perform app-level initialization, but the primary
44
purpose of the file is to pass control to the app’s first module.
55
*/
66

7-
import * as app from "tns-core-modules/application";
7+
import { Application } from "@nativescript/core";
88

9-
app.run({ moduleName: "app-root" });
9+
Application.run({ moduleName: "app-root" });
1010

1111
/*
1212
Do not place any code after the application has been started as it will not

demo/app/home/home-page.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as observable from 'tns-core-modules/data/observable';
2-
import * as pages from 'tns-core-modules/ui/page';
1+
import { EventData, Page } from '@nativescript/core';
32
import {HelloWorldModel} from './home-view-model';
43

54
// Event handler for Page 'loaded' event attached in main-page.xml
6-
export function pageLoaded(args: observable.EventData) {
5+
export function pageLoaded(args: EventData) {
76
// Get the event sender
8-
let page = <pages.Page>args.object;
7+
let page = <Page>args.object;
98
page.bindingContext = new HelloWorldModel();
109
}

demo/app/home/home-page.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page"
2-
xmlns:ui="nativescript-inappbrowser">
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page">
32
<StackLayout class="content" verticalAlignment="center">
43
<Label text="Welcome InAppBrowser&#xA;for NativeScript" class="t-20 text-center c-black" textWrap="true"/>
54
<Label text="Type the url" class="text-center p"/>

0 commit comments

Comments
 (0)