SSOAuth
Using Chrome Custom Tabs on Android and SFSafariViewController on iOS to achieve SSO Auth redirection to the application.
- This project is a fork of Advanced WebView Project
Here is a video showing off Chrome CustomTabs in NativeScript.
Android
iOS
Why use this? Because Perf Matters
DemowhateverYouLike
Android | iOS |
---|---|
Installation
To install execute (Coming soon...)
tns plugin add nativescript-ssoauth
Example
TypeScript
Initiate the service before the app starts e.g app.ts, main.ts
;init;
; public whateverYouLike
Important!
Listen for URL change by using CustomAppDelegate and call SSOAuthOpenUrlPostNotification
iOS
// custom-app-delegate-ios.ts
;
// app.ts
;; if isIOS
Android
To listen for application redirection in Android - specify your schema name (example: <data android:scheme="com.demoapp" />
)
together with other action and category.
API
- SSOAuthOpenUrl(options: SSOAuthOptions) // open URL
- SSOAuthExtractAppUrl(url: string) // extract returned URL and it's parameters
- SSOAuthOpenUrlPostNotification(url: string) // iOS only - post notification inside of ios.delegate
SSOAuthOptions Properties
- url: string
- toolbarColor: string
- toolbarControlsColor: string - ** iOS only **
- showTitle: boolean - ** Android only **
- isLogout: boolean
- onManualClose: Function
- successCompletionHandler: Function
Demo App
- fork the repo
- cd into
web
directory (recommend: use http-server to serve files on port 8080) - cd into the
src
directory - execute
npm run demo.android
ornpm run demo.ios
(these cmds are in the package.jsonscripts
section of the src if you're curious what is executing)