📲 Connect
Embed in Mobile App
Embed Connect in your mobile app using web views. Connect will broadcast an event with the message connect_exit
when you should dismiss the webview. See below for specific implementation details.
iOS
WKWebView
self.webView.configuration.preferences.javaScriptEnabled = true
self.webView.configuration
.userContentController.add(self, name: "connectMessageHandler")
self.webView.load( /*connect link request*/ )
Android
WebView
class JsObject {
@JavascriptInterface
public boolean postMessage(String message, String transferList) {
if (message.equals("connect_exit")) {
//dismiss the webview here
}
return true;
}
}
// And when initializing the webview
webView.addJavascriptInterface(new JsObject(), "connectMessageHandler");
Connect will post an event using the connectMessageHandler
object you created, with a message of connect_exit
. When your application receives that message, you should dismiss the Connect webview.
React Native
const onMessage = (event) => {
if (event?.nativeEvent?.data === 'connect_exit') {
//dismiss web view here
}
}
<WebView ... onMessage={onMessage} />
Connect will post an event using the onMessage
handler you created, with a message of connect_exit
. When your application receives that message, you should dismiss the Connect webview.
Need Addional Support?
If your application needs a different callback scheme, just let us know.