To integrate Portal, an organization adds a client library to their mobile app and a few server API endpoints.
Installation
We support Cocoa Pods and Swift Package Manager as distribution methods for our swift package.Setup
Add the
PortalSwift
package through Xcode:- In Xcode, right-click on your project in the Project Navigator
- Select “Add Packages…”
- In the search field, enter either:
- Package name:
PortalSwift
- Repository URL:
https://github.com/portal-hq/PortalSwift
- Package name:
- Select your desired version
- Click “Add Package”
Initializing Portal
To initializePortal
in your application, create a new instance of the Portal
class included in the package dependency you added. You can provide your Client API Key as the apiKey
argument during initialization. rpcConfig
is a map of CAIP-2 Chain IDs to their respective RPC URLs.
We can now create an instance of the Portal
class. Below is an example of how you can do this:
If you are using Client Session Tokens (CSTs), this hint is for you.When your user’s CST expires, all Portal SDKs will throw an error on the next MPC Operation the user makes (e.g. creating a wallet, backing up a wallet, recovering a wallet, or signing). That error will include a code
SESSION_EXPIRED
in the SDK methods, which you can use as an indicator to refresh your CST.