An example showing how to integrate trustshare using iOS.
This example shows how an iOS application can be integrated with the trustshare web sdk.
The app uses a WebView to load a page specifically developed for mobile integration.
Please refer to the web sdk documentation for further information and definitions for the various actions that can be carried out.
Clone the repo and change into the server directory.
Create a .env file and add the following:
TRUSTSHARE_PRIVATE_API_KEY=your-private-key
TRUSTSHARE_PUBLIC_API_KEY=your-public-keyThen run the following commands:
yarn # Install dependencies
yarn startOpen up the project in xCode and click build. It will open up a simulator with the example app running.
When the app launches, it will generate a create a payment intent by requesting a client_secret from the example server. The client secret is then used and loaded into the webview with the url https://checkout.trustshare.io.
The webview loads a route at https://checkout.trustshare.io, with your generated client secret on the end as a query parameter.
The resulting url should look similar to this:
https://checkout.trustshare.io/process?s=CLIENT_SECRET
The example app receives state updates from the webview using the ContentController class.
If the message name is the same as the provided handler, which defaults to "trustshareHandler", the message is passed on to the provided callback.
From here, we can use a JSONDecoder to decode the json messages and pass them into structs.
When the webview is closed, a handler will be called to let the iOS app know. If the checkout has been successful, there will be a project_id and a checkout_id in the message.
Please feel free to reach out to us on slack or contact support if you need further guidance on integration with iOS, and we'll do our best to help.
We are always looking for feedback, so we can provide the best possible developer experience. If you have any comments, suggestions, questions or feature requests, please let us know.