The launched event will emit a session token which can be used to resume a session. By default, OneSchema will save the session token and resume in case the session was not closed through normal means (usually the browser closing or refreshing). It will not resume if the user cancels the session or if it ends. This behavior is done through the saveSession param.
If you would like to manually resume a session, you can save the session token from the launched event and then later pass it into an importer session at launch. Once a session is complete (through success, error, or cancel), it should no longer be used to init.
The following code snippet shows how you can save the session token to a variable and use later. Consider also saving to something more persistent, like browser storage.
The parameters that can be passed to the launch function
close(clean = false)
The close function will hide the OneSchema iframe from view.
If true, will remove and clean up all listeners and remove the iframe from DOM. By default, false
The CSS class that should be set on the iframe. Replaces existing value
The CSS styles that should be set on the iframe. Replaces existing values
The HTML Element the iframe should be appended to. When called, the iframe will move in the DOM. This will cause the iframe's page to reload.
The iframe the class should manage. This will set the URL and event listeners for this iframe. This should be used with the OneSchemaParam manageDom set to false.
The success event will fire when the import is complete. The parameter to the callback will include the data that has been imported for "local" imports. The format of the data is documented here.
For webhook imports, the result will be an object with eventId and responses:
The eventId field will contain a string identifier that was included in the webhook requests. You can use this to associate the user’s session with the requests sent to your webhook. (You could also use the user JWT, which is also sent with the webhook requests, to do this.)
The responses field returns the bodies of the responses sent by your webhook endpoint. It is entirely fine to return nothing at all — you can return whatever data you’d like here. It will be array of objects with a body field containing the response, and a sequenceNumber field that indicates which request returned that response. Once this data is sent to your app you can use it however you want to guide the rest of the user’s import process.
The cancel event will fire when the import is cancelled.
The error event will fire when an error occurs during the import. The parameter to the callback will be a message about the error.
The launched event will fire when the iframe is ready to display. This will happen shortly after launch is called. The event data will include a field named sessionToken which can be used to resume a session manually.
Whether the iframe should automatically hide when completion events are emitted. Defaults to true.
Whether the SDK should save session information to browser storage so that an import can be resumed (if someone closes the browser and returns). The session is saved based on the JWT and template key. This will not save the session if it is 'cancelled'.
Defaults to true.
Whether the class should create and append an iframe to the DOM. If false, you will need to make an iframe and pass the reference to the class via setIframe so that it can be used. Defaults to true.
These values can be passed into the launch function or with the OneSchemaParams at initialization