Portal provides MPC wallets and dApp connections for organizations and their users.
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 this to your pod file:
...
pod 'PortalSwift', :git => 'https://github.com/portal-hq/PortalSwift.git'
...
Run pod install.
If you are running an xcode project and need to run pod init and run into ruby or xcode errors, ensure your xcode project is compatible with an xcode version lower than 14.
After you run pod install you should see a PROJECT_NAME.xcworkspace file. Open that file with xcode. You will need to work within that file to properly have the pod linked.
You must have access to our private repo: PortalSwift
Ensure you are signed in to your Github account within Xcode
Add the PortalSwift package through Xcode:
ClickAdd package after right-clicking on your project
Search for PortalSwift or use the url https://github.com/portal-hq/PortalSwift
Input the desired version and add the package.
Initializing Portal
We can now create an instance of the Portal class. Below is an example of how you can do this:
importPortalSwiftclassViewController:UIViewController {publicvar portal: Portal?publicvar clientApiKey: String="CLIENT_API_KEY"overridefuncviewDidLoad() { super.viewDidLoad() self.registerPortal(apiKey: self.clientApiKey) }funcregisterPortal(apiKey: String) ->Void {do {// Create a Portal instance. portal =tryPortal( apiKey: self.clientApiKey, // Request a Client Api Key from Portal's Rest API. backup: BackupOptions(icloud: ICloudStorage(), passwordStorage: PasswordStorage(), gdrive: GDriveStorage(clientID: GDRIVE_CLIENT_ID, viewController: self)),
chainId:5, keychain: PortalKeychain(), gatewayConfig: [5:"https://eth-goerli.g.alchemy.com/v2/[ALCHEMY_API_KEY]" ], version:"v1",// Optional autoApprove:true)// โ You successfully created a Portal instance! ๐print("Client API Key: ", portal?.apiKey) } catch ProviderInvalidArgumentError.invalidGatewayUrl {// โ Handle Invalid Gateway URL errors. } catch PortalArgumentError.noGatewayConfigForChain(let chainId) {// โ Handle when the gateway config does not match the chainId you specified. } catch {// โ Handle errors creating an instance of Portal. } }}
Now that we have our Portal instance, the next step is to generate a wallet. Let's create one!