API Documentation

App Detection

When a user opens your app, the initial request will include the appended URL parameter "wn_app". By analyzing the URL parameters, you can differentiate between website visits originating from a web browser and those from your mobile app. This approach is commonly employed in the back-end of a website.

For instance, if your start URL is "https://example.com", the initial call will be "https://example.com?wn_app=android".

To retain the state of the "wn_app" parameter beyond the initial request, it is important to store it in a persistent manner, such as using cookies. By doing so, you can access this information in subsequent requests, ensuring its availability throughout the user's session.

For example, with this method we've determined that you are visiting our website using a Web Browser.
PHP Example
if(isset($_GET['wn_app'])) {
    setcookie('wn_app', $_GET['wn_app']);
    echo 'User visit from Mobile App';
} else if(isset($_COOKIE['wn_app'])) {
    echo 'User visit from Mobile App';
} else {
    echo 'User visit from Web Browser';
}

To check whether a website visit originates from your mobile app, you can easily determine it on your website front-end by checking the existence of the "WebNativefier" JavaScript interface. If the interface is defined, it indicates that the visit is indeed from your mobile app.

With this method, we've determined that you are visiting our website using our Mobile App.
With this method, we've determined that you are visiting our website using a Web Browser.
JavaScript Example
if(typeof window.WebNativefier !== 'undefined') {
    console.log('User visit from Mobile App');
} else {
    console.log('User visit from Web Browser');
}

Make sure to visit this page through our Mobile App,
to try out each of the API calls below.

Get it on Google Play

URL API

To activate the built-in QR code scanner, simply launch the "qrcode://" URL. This scanner is specifically designed to scan URLs. However, please be aware that if you wish to scan barcodes or other data in addition to URLs, it is advisable to utilize the JavaScript API instead.

HTML Example
<a href="qrcode://">Scan QR-Code</a>

To initiate the Google Play In-App Review dialog within your app, simply launch the "ratedialog://" URL. This feature enables your users to rate your app and provide reviews directly from within the app. For more information on when and how often to implement this feature, please refer to the following link.

HTML Example
<a href="ratedialog://">Rate Dialog</a>

To clear the webview cache and all local cookies, simply launch the "clearcache://" URL. This action will effectively remove any stored cache data and cookies associated with the webview.

HTML Example
<a href="clearcache://">Clear Cache</a>

To enable push notifications for the user, launch the "enablepush://" URL. It's important to note that the user retains the ability to manually disable push notifications for your app in the app settings on their phone, despite enabling it through this URL.

HTML Example
<a href="enablepush://">Enable Push</a>

To disable push notifications for the user, launch the "disablepush://" URL. This action will effectively turn off push notifications for the user, preventing them from receiving any further notifications from your app.

HTML Example
<a href="disablepush://">Disable Push</a>

JavaScript API

By invoking the "scan_qrcode" function, an integrated QR code scanner will open, allowing users to scan URLs, barcodes and other data.

Upon successful scanning, the function will return a callback named "scan_qrcode" that returns the scanned value as the result.

JavaScript Example
WebNativefier.scan_qrcode();

By invoking the "show_rate_dialog" function, the app will attempt to display the Google Play In-App Review dialog, enabling your users to rate your app and provide reviews directly from within your app. For detailed instructions on when and how frequently to use this function, please refer to the following link.

Upon successful execution, the function will return a callback named "show_rate_dialog". However, it's important to note that the display of the dialog itself is determined by the Google Play API and may not be guaranteed despite the successful execution of the function.

JavaScript Example
WebNativefier.show_rate_dialog();

To clear the webview cache and all local cookies, you can invoke the "clear_cache" function. This function will effectively remove any stored cache data and cookies associated with the webview.

Upon successful execution of the function, a callback named "clear_cache" will be returned.

JavaScript Example
WebNativefier.clear_cache();

To display a native toast message to the user, utilize the "show_toast" function.

Upon successful execution of the function, a callback named "show_toast" will be returned.

JavaScript Example
WebNativefier.show_toast('This is a toast message!');

To enable push notifications for the user, simply invoke the "enable_push" function. It's important to note that the user retains the ability to manually disable push notifications for your app in the app settings on their phone, despite enabling it through this function.

Upon successful execution of the function, a callback named "enable_push" will be returned.

Note: This function is available only for apps that have enabled the OneSignal add-on.
JavaScript Example
WebNativefier.enable_push();

To disable push notifications for the user, make use of the "disable_push" function. This action will effectively turn off push notifications for the user, preventing them from receiving any further notifications from your app.

Upon successful execution of the function, a callback named "disable_push" will be returned.

Note: This function is available only for apps that have enabled the OneSignal add-on.
JavaScript Example
WebNativefier.disable_push();

To retrieve the OneSignal "subscription_id" for the user, simply call the "get_subscription_id" function. Please check the OneSignal Users guide for more info.

Upon successful execution of the function, it will return a callback named "get_subscription_id" that returns the corresponding "subscription_id" value.

Note: This function is available only for apps that have enabled the OneSignal add-on.
JavaScript Example
WebNativefier.get_subscription_id();

To set the OneSignal "external_user_id" for the user, use the "onesignal_login" function. Please check the OneSignal Aliases & External ID guide for more info.

Upon successful execution of the function, a callback named "onesignal_login" will be triggered to indicate the successful completion of the operation.

Note: This function is available only for apps that have enabled the OneSignal add-on.
JavaScript Example
WebNativefier.onesignal_login('123456789');

To remove the OneSignal "external_user_id" from the user, make use of the "onesignal_logout" function. Please check the OneSignal Users & Segments guide for more info.

Upon successful execution of the function, a callback named "onesignal_logout" will be triggered to indicate the successful completion of the operation.

Note: This function is available only for apps that have enabled the OneSignal add-on.
JavaScript Example
WebNativefier.onesignal_logout();

JavaScript Callbacks

In our JavaScript API, every function is accompanied by a callback that is invoked upon successful execution. To avoid multiple callback functions for each method, we have implemented a unified callback function, called "WebNativefier.callback", with two string parameters: "name" and "value".

The "name" parameter represents the name of the function from which the callback originates, while the "value" parameter is an optional return value associated with that function.

Here is an example definition of the callback function:

WebNativefier.callback = (name, value) => {
    // Your code here
}

You can modify the code within the callback function to handle the specific logic you require based on the "name" and "value" parameters.

Feel free to test each of the API calls mentioned above from our mobile app, and you can observe the associated callbacks in the console log displayed below.


                        

Ready to launch your app?

Please submit your website URL to launch the configurator