Wix Answers Mobile SDK for React Native

Relevant for Widgets That Authenticate Users, Only
The contents on this page are relevant only for widget that authenticate users. You must first enable SSO Authentication while customizing your widget's advanced settings.
Wix Answers SDK for React Native enables your users to access the Wix Answers widget from inside your application. Your users will have access to all of the existing widget features:
  • Live chat
  • KB articles
  • Contact form
  • Request callback
  • and more!

Getting Started

$ npm install react-native-wixanswers-sdk --save
$ cd ios && pod install
See the corresponding documentation for additional configuration and options:
Note
This module does not support Expo.
Add this code to your native app for basic configuration.
1
2
3
4
5
6
7
8
9
import WixanswersSdk from 'react-native-wixanswers-sdk';

WixanswersSdk.configure('TENANT_NAME', 'WIDGET_ID', async (setToken) => {
  const token = await MY_USER_AUTHENTICATION_FUNCTION(); // <-- implement this function to authenticate via your own server
  setToken(token);
}, '<locale>');

// after the SDK is configured
WixanswersSdk.openWidget();
Replace '<locale>' with a language code string to load the widget in that language. If you remove this parameter, the default language is English ('en').

Methods

configure(tenant_name:string, widget_id:string, auth_func:async function, locale:string)

Configure the widget. Call this in an onLoaded block.

Return: None
1
2
3
4
WixanswersSdk.configure('TENANT_NAME', 'WIDGET_ID', async (setToken) => {
  const token = await MY_USER_AUTHENTICATION_FUNCTION(); // <-- implement this function to authenticate via your own server
  setToken(token);
}, '<locale>');

onLoaded()

Run a block or code after the widget is loaded. Call this before configure.

Return: None
1
2
3
WixanswersSdk.onLoaded(() => {
  // Code Goes Here...
});

openWidget()

Display the widget. Call this after configuring the widget (configure) in an onLoaded block.

Return: None
1
WixanswersSdk.openWidget();

setFeaturedArticles(articles:list of article IDs)

Dynamically set the featured articles in the widget. You must call this in an onLoaded block before opening the widget (openWidget).

Return: None
1
2
3
WixanswersSdk.onLoaded(() => {
    WixanswersSdk.setFeaturedArticles(['fef78571-7a8c-4fa9-b48c-8f106fa16ca8'])
});