Javascript API Documentation
It is a javascript API that allows you to control the web view and the push-only prototype app provided by Swing2App.
In short, include and use the following js file through the API specification below and perform the functions you need.
Common js file Please include the following js file in your HTML file
WebView Javascript API Specifications
Webview Control Related Methods
• Webview Backwards
To Move to the previous page in the webview app. Same style as the back function in the web browser
• Webview Forward
Move to the front page in the webview app. Same style as the forward function in the web browser
• Go to Webview Home
Ability to navigate from the webview app to the home page (set initial page) set in the Swing2App.
• Clean Web Cache
Command to Clear Cache in WebView
*Available from js lib version 2024_02_28_002
Controlling the Toolbar methods
• Enabling the Toolbar
You can control the Toolbar via API in a push-only prototype.
You can hide, enable, and set the auto-hide option for the toolbar while the app is running.
*Available from js lib version 2024_02_28_002
Application-related methods
• Get platform information
Functions for getting platform information from the web
• Get version and device information
A function that gets the version of the app and the H/W and S/W information of the device
• Close application
Command to terminate a running app
• Run a URL with an external browser
If you want to open a specific page with the default browser of an app such as Chrome or Safari, you can use the following function.
• Run URLs with the embedded browser
Run using Android and iOS's own built-in browser.
If you must use Chrome and Safari, you can operate Chrome and Safari from inside the app through the code below.
• Share the current page
Run the code below for the current Web page-sharing feature
• Share a custom URL
If you want to share the specified URL, run the code as shown below.
• Checking the notification setting status of the application
Ability to check the status of push alarm settings in the application.
If the push is disabled or if the push is turned off by the OS itself,
You can check if the app is turned off with its own settings.
Ex:) Code example for recommending activation when Off setting according to push setting
Ability to move alarm settings of applications or systems
(1) Go to the screen where you can set the alarm by the application itself
(2) Go to the screen where you can set your own alarm for the system (Android, iOS)
• Saving Text to Clipboard
A feature that allows you to save text to the clipboard.
Due to security issues, the window.navigator.clipboard.writeText
API does not function properly in WebView.
In Swing2App WebView, you can use the following API to save text to the clipboard.
• Activate Push Notification
API to active push notification
• Inactivate Push Notification
API to inactive push notification
• Saving Variables on the Device
Saving Storage Variables within the App
If you have data you want to store in the app's storage, you can use the following function to save it.
You can utilize this feature to easily implement automatic website login.
*Available from js lib version 2024_02_28_002
• Retrieving Saved Variables on the Device
Fetching Stored Variable Values within the App
*Available from js lib version 2024_02_28_002
• Playing TTS (Premium Feature) - Customization Required
Function to enable the TTS feature that converts text to speech
*Available from js lib version 2024_02_28_002
• Checking First App Launch
API to check if the app is being launched for the first time, a function to determine the first launch of the app
*Available from js lib version 2024_02_28_002
Methods for Controlling App UI
• Setting Background Color for iOS
An option to set the SafeArea region and main color due to the device notch and home bar UI on iOS.
Please input the color as a hex value without the # symbol.
This setting only works on iOS.
*Available from js lib version 2024_02_28_002
Method for Controlling App Screen
• Navigating to Settings Screen
API command to navigate to the settings screen.
You can move to the settings screen without using the toolbar or menu bar.
*Available from js lib version 2024_02_28_002
• Navigating to Notification List Screen
API command to navigate to the notification list screen.
You can move to the notification list screen without using the toolbar or menu bar.
*Available from js lib version 2024_02_28_002
• Navigating to Menu Screen
API command to navigate to the menu screen.
You can move to the menu screen without using the toolbar.
*Available from js lib version 2024_02_28_002
• Navigating to Bookmark List Screen
API command to navigate to the bookmark list screen.
You can move to the bookmark list screen without using the menu or toolbar.
*Available from js lib version 2024_02_28_002
Application Event
Commands to manage the app's native events.
• Adding WebView Navigation Event for Android App Back Key
When you add an exit event to the app's Back button, the back navigation function triggered by the Back button will not work.
Therefore, if you add a backEvent, you need to implement the back navigation function yourself, as it will not work when the WebView navigation goes back due to the Back key.
• Adding Exit Event for Android App Back Key
When you add an exit event to the app's back button, the app will not exit when the back button is pressed.
Therefore, if you add a backExitEvent, you need to implement the exit functionality directly within the callback function.
Methods related to AdMob
This is a command that allows you to manage in-app AdMob ads directly from the website.
Please refer to the information below to use the ads.
This command only works for apps with ad mob enabled
• Show banner ads
Commands to display AdMob banner ads in applications
adId
Enter banner ad unit ID
ca-app-pub-3940256099942544/6300978111
End banner ads
Command to stop AdMob banner ads in the application
Show interstitial ads
Commands to display AdMob interstitial ads in applications
adId
Enter interstitial unit ID
ca-app-pub-3940256099942544/6300978111
Last updated