Upscope supports Swift Package Manager and CocoaPods.
To install Upscope using Swift Package Manager you can follow the tutorial published by Apple using the URL for the Upscope repo with the current version:
- In Xcode, select “File” → “Add Packages...”
- Enter /~https://github.com/upscopeio/cobrowsing-sdk-ios
or you can add the following dependency to your Package.swift
:
.package(url: "/~https://github.com/upscopeio/cobrowsing-sdk-ios", from: "2025.1.0")
If you do not yet have Podfile, run the command to create it:
pod init
Add the pod to your Podfile:
pod 'UpscopeIO'
And then run:
pod install
After installing the cocoapod into your project and opening .xcworkspace file, import UpscopeIO with
import UpscopeIO
In order to use UpscopeIO first of all you should initialize a single Upscope manager with your private apiKey:
let upscopeManager = UpscopeManager(apiKey: myApiKey)
Also you can use additional configurations on your choice
let upscopeManager = UpscopeManager(
apiKey: <myApiKey>,
agentPrompt: ...,
identities: ...,
integrationIds: ...,
tags: ...,
uniqueId: ...
)
All of these additional properties can be updated in the future if you need this with
upscopeManager.updateOptions(agentPrompt: .value("Something new!"))
Right after this if you have autoConnect option set to true you will be automatically connected to web socket. Otherwise, you need to connect manually:
upscopeManager.connect()
Methods to subscribe for all events can be used in a such way:
for event in MessageType.allCases {
upscopeManager.on(event: event) { [weak self] data in
// your way to handle the data
}
}
To unsubscribe you can use 'off' method:
for event in MessageType.allCases {
upscopeManager.off(event: event)
}
UpscopeIO is available under the MIT license. See the LICENSE file for more info.