Supporting mobile devices
TalkJS works well in mobile web browsers and inside mobile apps, using a WebView. On this page you'll find an overview of resources, as well as ways to further enhance the user experience on mobile.
The following resources can help you integrate TalkJS into your React Native app:
The following resources can help you integrate TalkJS into your Flutter app:
If you embed TalkJS into a native app using WebView, you can add support for mobile push notifications.
TalkJS works well inside apps built using Cordova, PhoneGap, and the Ionic framework. The following resources can help you integrate TalkJS into your app:
To make everything work smoothly, also consider adding the following settings:
On some platforms, you need to add the TalkJS URIs to an allow list to be able to load TalkJS. You can do this as follows:
- Using Cordova Allow List, add a Content Security Policy rule that allows access to
https://*.talkjs.com
. - TalkJS uses Google Cloud to enable file sharing. If you use file sharing, also add
https://firebasestorage.googleapis.com
to the allow list.
By default, Cordova opens all links inside your app. If you would like your users also to be able to open links in the device's system browser, then install cordova-plugin-inappbrowser. Despite its name, this plugin includes a feature to avoid using an in-app browser.
TalkJS automatically detects the presence of cordova-plugin-inappbrowser
and ensures that external links open in the device's system browser.
This section provides troubleshooting instructions for issues that you may come across.
Is the TalkJS chat UI not displaying at full width? Try one of the following:
- Check that the WebView inside of which a website with the TalkJS UI is displayed is set to 100%. TalkJS can only take up as much space as available within the WebView.
- Check that the width of the website that's inside the WebView is set to be the device's width. You can use the following code to fix the viewport width:
1<meta2 name="viewport"3 content="width=device-width"4/>
- If you're using one of the TalkJS mobile SDKs, then the width of the website inside the WebView is automatically set to be the device's width.
- Check that in the Layout section of the theme editor in your TalkJS dashboard, the width of the TalkJS UI is set to 100%.
Did you implement React Native prior to the release of the React Native SDK? Then by default on iOS, if a user opens an external link or attachment from a chatbox, it opens in the same window and they won't be able to go back.
To ensure that external links and attachments open correctly on iOS, you can use the onShouldStartLoadWithRequest
callback. Once this callback is triggered, you can open the link in an external browser using React Native's Linking
module, for example as follows:
1import { Linking, Platform } from 'react-native';23const webview = React.createRef();45return (6 <WebView7 ref={webview}8 source={{ html: html, baseUrl: baseUrl }}9 //TalkJS initialization code10 injectedJavaScript={injectedJavaScript}11 onShouldStartLoadWithRequest={(request) => {12 const url = request.url;13 if (14 Platform.OS === 'ios' &&15 request.navigationType === 'click' &&16 Linking.canOpenURL(url)17 ) {18 Linking.openURL(url); // Open link in separate Safari window.19 return false; // Stops WebView from loading the clicked link.20 }21 return true;22 }}23 />24);