Skip to content

Commit

Permalink
Merge pull request #28 from proyecto26/release/v2.3.0
Browse files Browse the repository at this point in the history
Update version to 2.3.0
  • Loading branch information
jdnichollsc authored Apr 9, 2020
2 parents 129d4e7 + c2f0d79 commit 9fe45da
Show file tree
Hide file tree
Showing 19 changed files with 975 additions and 637 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ in case of vulnerabilities.

## [Unreleased]

## [2.3.0] - 2020-04-08
### Added
- Added `ephemeralWebSession` option to supports `ephemeralWebBrowserSession` on iOS 13.
- Fix issue loading initial url from Android resume event for authentication purposes.

## [2.2.0] - 2019-11-14
### Added
- Validate if the **type** of the auth result is different to `cancel` before to check the url of the last redirection from **Android**.
Expand Down Expand Up @@ -60,7 +65,8 @@ in case of vulnerabilities.
- Methods to open and close external urls to authenticate the user **(openAuth, closeAuth)** using deep linking.
- `isAvailable` method to detect if the device supports the plugin.

[Unreleased]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.2.0...HEAD
[Unreleased]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.3.0...HEAD
[2.3.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.1.1...v2.2.0
[2.1.1]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/proyecto26/nativescript-inappbrowser/compare/v2.0.0...v2.1.0
Expand Down
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Property | Description
`modalTransitionStyle` (String) | The transition style to use when presenting the view controller. [`coverVertical`/`flipHorizontal`/`crossDissolve`/`partialCurl`]
`modalEnabled` (Boolean) | Present the **SafariViewController** modally or as push instead. [`true`/`false`]
`enableBarCollapsing` (Boolean) | Determines whether the browser's tool bars will collapse or not. [`true`/`false`]
`ephemeralWebSession` (Boolean) | Prevent re-use cookies of previous session (openAuth only) [`true`/`false`]

### Android Options
Property | Description
Expand Down Expand Up @@ -147,7 +148,7 @@ import InAppBrowser from 'nativescript-inappbrowser'
In order to redirect back to your application from a web browser, you must specify a unique URI to your app. To do this,
define your app scheme and replace `my-scheme` and `my-host` with your info.

- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/Android/src/main/AndroidManifest.xml#L45)**
- Enable deep linking (Android) - **[AndroidManifest.xml](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/Android/src/main/AndroidManifest.xml#L41)**
```
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand All @@ -157,7 +158,7 @@ define your app scheme and replace `my-scheme` and `my-host` with your info.
</intent-filter>
```

- Enable deep linking (iOS) - **[Info.plist](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/iOS/Info.plist#L28)**
- Enable deep linking (iOS) - **[Info.plist](https://github.com/proyecto26/nativescript-inappbrowser/blob/master/demo/app/App_Resources/iOS/Info.plist#L21)**
```
<key>CFBundleURLTypes</key>
<array>
Expand All @@ -174,6 +175,50 @@ define your app scheme and replace `my-scheme` and `my-host` with your info.
</array>
```

- utilities.ts
```javascript
import { android } from "tns-core-modules/application";
export const getDeepLink = (path = "") => {
const scheme = 'my-scheme';
const prefix = android ? `${scheme}://my-host/` : `${scheme}://`;
return prefix + path;
}
```

- home-page.ts
```javascript
import { openUrl } from 'tns-core-modules/utils/utils';
import InAppBrowser from 'nativescript-inappbrowser';
import { getDeepLink } from './utilities';
...
async onLogin() {
const deepLink = getDeepLink("callback")
const url = `https://my-auth-login-page.com?redirect_uri=${deepLink}`
try {
if (await InAppBrowser.isAvailable()) {
InAppBrowser.openAuth(url, deepLink, {
// iOS Properties
ephemeralWebSession: false,
// Android Properties
showTitle: false,
enableUrlBarHiding: true,
enableDefaultShare: false
}).then((response) => {
if (
response.type === 'success' &&
response.url
) {
openUrl(response.url)
}
})
} else openUrl(url)
} catch (error) {
openUrl(url)
}
}
...
```

### Authentication

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).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="-100%" android:toXDelta="0%"/>
<alpha android:duration="500" android:fromAlpha="0.0" android:toAlpha="1.0" />
</set>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="100%" android:toXDelta="0%" />
<alpha android:duration="500" android:fromAlpha="0.0" android:toAlpha="1.0" />
</set>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="0%" android:toXDelta="-100%"/>
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.0" />
</set>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate android:duration="500" android:fromXDelta="0%" android:toXDelta="100%"/>
<alpha android:duration="500" android:fromAlpha="1.0" android:toAlpha="0.0" />
</set>
2 changes: 1 addition & 1 deletion demo/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In many cases you may want to use the NativeScript core theme instead
of writing your own CSS rules. For a full list of class names in the theme
refer to http://docs.nativescript.org/ui/theme.
*/
@import '~nativescript-theme-core/css/core.light.css';
@import '~nativescript-theme-core/css/core.css';

TextField {
border-width: 1;
Expand Down
49 changes: 25 additions & 24 deletions demo/app/home/home-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable } from 'tns-core-modules/data/observable';
import { openUrl } from 'tns-core-modules/utils/utils';
import { alert } from 'tns-core-modules/ui/dialogs';
import InAppBrowser from 'nativescript-inappbrowser';
import { android } from "tns-core-modules/application";
import { getDeepLink, sleep } from './utilities';

export class HelloWorldModel extends Observable {
private _url: string;
Expand All @@ -25,11 +25,7 @@ export class HelloWorldModel extends Observable {
}
}

sleep (timeout) {
return new Promise(resolve => setTimeout(resolve, timeout));
}

openLink = async () => {
async openLink() {
try {
const { url } = this;
if (await InAppBrowser.isAvailable()) {
Expand Down Expand Up @@ -63,7 +59,7 @@ export class HelloWorldModel extends Observable {
'my-custom-header': 'my custom header value'
}
});
await this.sleep(800);
await sleep(800);
alert({
title: 'Response',
message: JSON.stringify(result),
Expand All @@ -83,24 +79,29 @@ export class HelloWorldModel extends Observable {
}
}

getDeepLink = (path = '') => {
const scheme = 'my-demo';
const prefix = android ? `${scheme}://demo/` : `${scheme}://`;
return prefix + path;
}

tryDeepLinking = async () => {
const loginUrl = `https://proyecto26.github.io/react-native-inappbrowser/`;
const redirectUrl = this.getDeepLink('home');
async tryDeepLinking() {
const loginUrl = `https://proyecto26.github.io/react-native-inappbrowser`;
const redirectUrl = getDeepLink('home');
const url = `${loginUrl}?redirect_url=${encodeURIComponent(redirectUrl)}`;
if (await InAppBrowser.isAvailable()) {
const result = await InAppBrowser.openAuth(url, redirectUrl);
await this.sleep(800);
alert({
title: 'Response',
message: JSON.stringify(result),
okButtonText: 'Ok'
});
try {
if (await InAppBrowser.isAvailable()) {
const result = await InAppBrowser.openAuth(url, redirectUrl, {
// iOS Properties
ephemeralWebSession: true,
// Android Properties
showTitle: false,
enableUrlBarHiding: true,
enableDefaultShare: true
});
await sleep(800);
alert({
title: 'Response',
message: JSON.stringify(result),
okButtonText: 'Ok'
});
}
} catch {
alert('Something’s wrong with the app :(');
}
}
}
11 changes: 11 additions & 0 deletions demo/app/home/utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { android } from "tns-core-modules/application";

export const getDeepLink = (path = "") => {
const scheme = 'my-demo';
const prefix = android ? `${scheme}://demo/` : `${scheme}://`;
return prefix + path;
};

export const sleep = (timeout: number) => {
return new Promise(resolve => setTimeout(resolve, timeout));
};
Loading

0 comments on commit 9fe45da

Please sign in to comment.