To install execute:
ns plugin add nativescript-advanced-webview
tns plugin add nativescript-advanced-webview@5.0.0
Here is a video showing off Chrome CustomTabs in NativeScript.
Android | iOS |
---|---|
![]() |
![]() |
Initiate the service before the app starts e.g app.ts, main.ts
import { init } from 'nativescript-advanced-webview';
init();
import {
AdvancedWebviewEvents,
AdvancedWebViewOptions,
init,
NSAdvancedWebViewEventEmitter,
openAdvancedUrl
} from 'nativescript-advanced-webview';
import { getRootView } from '@nativescript/core/application';
function whateverYouLike() {
NSAdvancedWebViewEventEmitter.once(AdvancedWebviewEvents.LoadStarted, () => {
console.log('LOAD STARTED');
});
NSAdvancedWebViewEventEmitter.once(AdvancedWebviewEvents.LoadFinished, () => {
console.log('LOAD FINISHED');
});
NSAdvancedWebViewEventEmitter.once(AdvancedWebviewEvents.LoadError, () => {
console.log('LOAD ERROR');
});
NSAdvancedWebViewEventEmitter.once(AdvancedWebviewEvents.Closed, () => {
console.log('CLOSED');
});
const opts: AdvancedWebViewOptions = {
url: 'https://nativescript.org',
showTitle: true,
toolbarColor: '#336699',
toolbarControlsColor: '#fff',
ios: {
viewController: getRootView().viewController
}
};
openAdvancedUrl(opts);
}
src
directorynpm run demo.android
or npm run demo.ios