I want to call some function in app once user submits the typeform. I know submit returns the result callback in onSubmit() but how can I receive callback in app using this function name only? I checked the documentation but could not find anything related to mobile apps integration.
Answered
Handle onSubmit callback from typeform in Android and iOS
Best answer by mathio-tf
Hello
our embed SDK is written in JavaScript. You can execute any JS code in the onSubmit callback. See the docs on our dev portal about callbacks.
If you are using a JS framework (such as CapacitorJS) you can execute your JS code right in the callback.
I dont have much experience with building native apps. However if you are building a native app you could use this approach:
- display webview with local HTML page
- the page will contain Typeform embed SDK code, eg.
<div id="form"></div> <script src="//embed.typeform.com/next/embed.js"></script> <script> window.tf.createWidget('<form-id>', { container: document.querySelector('#form'), onSubmit: () => { // your custom code here } }) </script>
-
in the onSubmit method you can send data to your native code - see this Medium article on how to do this: https://medium.com/@sreeharikv112/communication-from-webview-to-native-ios-android-app-6d842cefe02d
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.