SpeedifySDK

class SpeedifySDK : NSObject, SpeedifyDelegate

This is the entry point of the Speedify SDK. Initialize SpeedifySDK by using the sharedInstance property.

  • Subscribe to this delegate if you wish to be alerted when the SpeedifySDK returns the current:

    Declaration

    Swift

    var delegate: SpeedifySDKDelegate?
  • Undocumented

    Declaration

    Swift

    static let sharedInstance: SpeedifySDK
  • Undocumented

    Declaration

    Swift

    private(set) public var state: State?
  • Undocumented

    Declaration

    Swift

    private(set) public var version: Version?
  • Current AdapterData. If set to nil, no data available.

    Declaration

    Swift

    private(set) public var adapterData: [AdapterData]?
  • Current ServerInformation. If set to nil, no server is connected.

    Declaration

    Swift

    private(set) public var serverInformation: ServerInformation?
  • Undocumented

    Declaration

    Swift

    private(set) public var settings: Settings?
  • Undocumented

    Declaration

    Swift

    private(set) public var stats: [ConnectionStats]?
  • Undocumented

    Declaration

    Swift

    private(set) public var accountingData: AccountingData?
  • Undocumented

    Declaration

    Swift

    private(set) public var privacySettings: PrivacySettings?
  • Undocumented

    Declaration

    Swift

    var stateDelegate: SpeedifyStateDelegate?
  • Undocumented

    Declaration

    Swift

    var adapterDelegate: SpeedifyAdapterDelegate?
  • Undocumented

    Declaration

    Swift

    var accountingDelegate: SpeedifyAccountingDelegate?
  • Undocumented

    Declaration

    Swift

    var sessionStatsDelegate: SpeedifySessionStatsDelegate?
  • Undocumented

    Declaration

    Swift

    var connectionStatsDelegate: SpeedifyConnectionStatsDelegate?
  • Undocumented

    Declaration

    Swift

    var settingsDelegate: SpeedifySettingsDelegate?
  • Undocumented

    Declaration

    Swift

    var settingsLockDelegate: SpeedifySettingsErrorDelegate?
  • Undocumented

    Declaration

    Swift

    var localSettingsVendorDelegate: SpeedifyLocalSettingsVendorDelegate?
  • Undocumented

    Declaration

    Swift

    var remoteSettingsVendorDelegate: SpeedifyRemoteSettingsVendorDelegate?
  • Undocumented

    Declaration

    Swift

    var firewallSettingsDelegate: SpeedifyFirewallSettingsDelegate?
  • Undocumented

    Declaration

    Swift

    var pendingCompletionHandler: ((Bool) -> Void)?
  • Undocumented

    Declaration

    Swift

    override init()
  • Undocumented

    Declaration

    Swift

    func update(completionHandler:@escaping (_ done: Bool?)->Void)
  • Start the PacketTunnel app extension.

    This must be called to ensure message accuracy and the ability to keep the tunnel open. This checks the app extension state for

    • Invalid
    • Disconnecting
    • Disconnected

    Upon reaching these states the function ensures the tunnel will be open. The timer fires every second to check the Tunnel State.

    Declaration

    Swift

    func startTunnel()
  • Connect to a server by an automatic selection method. If already connected, this will disconnect before reconnecting.

    • closest: Closest public or private server to user
    • closestPrivate: Closest private server to user
    • last: Selects the last connected server
    • p2p: Server that supports P2P/BitTorrent

    Declaration

    Swift

    func connectAuto(connectOption: AutoConnectMethod, completionHandler:@escaping (_ serverInformation: ServerInformation?, _ error: ErrorType)->Void)

    Parameters

    connectOption

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific city. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    func connectByCity(country: String, city: String,completionHandler:@escaping (_ message: ServerInformation?, _ error: ErrorType)->Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’

    city

    City code, ie: ‘atlanta’

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific country. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    func connectByCountry(country: String, completionHandler:@escaping (_ message: ServerInformation?, _ error: ErrorType)->Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’.

    Return Value

    completionHandler: ServerInformation

  • Connect to a server with a specific server number i.e 5. If already connected, this will disconnect before reconnecting.

    Declaration

    Swift

    func connectByServer(country: String, city: String, num: Int, completionHandler:@escaping (_ message: ServerInformation?, _ error: ErrorType)->Void)

    Parameters

    country

    2-character ISO country code, ie: ‘us’.

    city

    City code, ie: ‘atlanta’

    num

    Specific server number i.e 5

    Return Value

    completionHandler: ServerInformation

  • Disconnect from the server.

    Declaration

    Swift

    func disconnect()
  • Authenticate a new user.

    Declaration

    Swift

    func login(username: String, password: String, completionHandler:@escaping (_ message: State?, _ error: ErrorType)->Void)

    Parameters

    username

    Username of the user you wish to authenticate

    password

    Password of the user you wish to authenticate

    Return Value

    completionHandler: State and optional ValidationError

    • Authenticate a new user using and oauth access token. You are responsible for fetching updated access tokens if you use this method.
    • If setting a custom directory, call changeDirectoryURL(url: String) before calling this.
    • Login errors will be signalled in completionHandler error.
    • An expired access token will give an error of ErrorType.token_expired, while invalid tokens will give ErrorType.credential. *

    Declaration

    Swift

    func loginOauth(oauthAccessToken: String, completionHandler:@escaping (_ error: ErrorType)->Void)
  • Logout the current user.

    Declaration

    Swift

    func logout(completionHandler:@escaping (_ message: State?)->Void)

    Return Value

    completionHandler: State

  • Change the basic mode of operation, between optimizing for speed or maximizing reliability.

    Declaration

    Swift

    func setMode(mode: BondingMode)

    Parameters

    mode

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings)

  • Get a list of available servers from the directory list.

    Declaration

    Swift

    func getDirectory(completionHandler:@escaping (_ message: Dictionary<String, Any>)->Void)

    Return Value

    completionHandler: A dictionary containing a server list

  • Change directory server used for user authentication and server management. If using your own directory server, this should be called before login or loginAutoAccount.

    Declaration

    Swift

    func setDirectoryDomain(domain: String, completionHandler:@escaping (_ domain: String)->Void)
  • Reset the directory server to defaults.

    Declaration

    Swift

    func resetDirectoryDomain(completionHandler:@escaping (_ domain: String)->Void)
  • Get the current State.

    Declaration

    Swift

    func getState(completionHandler:@escaping (_ message: State?)->Void)

    Return Value

    completionHandler: State

  • Get the libspeedify version.

    Declaration

    Swift

    func getVersion(completionHandler:@escaping (_ message: Version)->Void)

    Return Value

    completionHandler: Version

  • Subscribe or Unsubscribe from receiving the tunnel ConnectionStats and SessionStats.

    Important

    Important note: This must be enabled to receieve ConnectionStats updates.

    Example of some SessionStats.

    • Number of Failovers
    • Total Connected Minutes
    • Fastest Connected Mbps

    Example of some ConnectionStats.

    • Time Connected
    • total bytes per second
    • guid

    Declaration

    Swift

    func enableConnectionStatUpdates(enabled: Bool)

    Return Value

    completionHandler: SessionStats

  • Declaration

    Swift

    func getConnections(completionHandler:@escaping (_ message: [AdapterData]?)->Void)

    Return Value

    completionHandler: AdapterData

  • Set local vendor settings @param settingsJson a json object

    • Current value available from “. @param merge if true, settingsJson is merged in to existing local vendor settings. if false, settingsJson replaces existing local vendor settings @since future

    Declaration

    Swift

    func setLocalVendorSettings(settings: Settings, merged: Bool)
  • Gets the local vendor settings @since 9.2

    Declaration

    Swift

    func refreshLocalVendorSettings()
  • Get configuration of the firewall @since 9.2

    Declaration

    Swift

    func refreshFirewall()
  • Set the mode used by the firewall. @param mode how matches are treated @since 9.2

    Declaration

    Swift

    func setFirewallMode(mode: FirewallMode)
  • Set domains to firewall. @param domains domain names to block/whitelist @since 9.2

    Declaration

    Swift

    func setFirewallDomains(domains: [String])
  • Set IPv4 address to firewall. @param ipv4 ipv4 addresses to block/whitelist @since 9.2

    Declaration

    Swift

    func setFirewallIPv4(ipv4: [String])
  • Set ports to firewall. @param ports ports to be firewalled @since 9.2

    Declaration

    Swift

    func setFirewallPorts(ports: [FirewallPort])
  • Gets the remote vendor settings @since 9.2

    Declaration

    Swift

    func refreshRemoteVendorSettings()
  • Change the ConnectionPriority of each connection on the device.

    • Call the function getConnections(completionHandler:@escaping (_ message: Dictionary<String, Any>)->Void) before calling this function to ensure adapters are present.

    Possible ConnectionPriority options include

    • ALWAYS = 0
    • SECONDARY = 1
    • BACKUP = 2
    • NEVER = 100

    Declaration

    Swift

    func setConnectionPriorities(connection: String, priority: ConnectionPriority)

    Parameters

    connection

    Should be ‘en0’ or ‘cellular’. The getConnections function will retrieve the list for you.

    priority

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData])

  • Change which directory servers to connect with.

    • If using your own directory server, this should always be called before login() or loginAutoAccount().

    Declaration

    Swift

    func changeDirectoryURL(url: String)

    Parameters

    newURL

    Pass in a host name or ‘Empty’ field to change it back to the original server list

    Return Value

    completionHandler: A dictionary containing the Connections and Session stats.

  • Change the encryption settings per adapter.

    Declaration

    Swift

    func setConnectionEncryption(adapterID: String, encrypt: Bool)

    Parameters

    connection

    This should be an active adapter on the device. i.e NetworkType

    encrypt

    A boolean value to determine if encryption should be on or off

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData])

  • Change the encryption settings on the tunnel.

    Declaration

    Swift

    func setTunnelEncrypted(encrypted: Bool)

    Parameters

    encrypt

    A boolean value to determine if encryption should be on or off.

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData]).

  • Allow or disallow use of ChaCha for connection encryptions. Current value available from Settings.

    Declaration

    Swift

    func setChaChaEncrypted(encrypted: Bool)

    Parameters

    encrypt

    A boolean value to determine if ChaCha encryption should be on or off.

    Return Value

    This will show updated information inside of the delegate function func connectionDataDidUpdate(connectionData: [AdapterData]).

  • Set reporting encryption key.

    Declaration

    Swift

    func setReportingEncryptionKey(key128bit: String)

    Parameters

    key128bit

    key A 16 byte ascii or 32byte hex string used to encrypt sensitive reports, or null to use default.

  • Set the overflow threshold.

    Declaration

    Swift

    func setOverflowThreshold(mbpsOverflow: Double)

    Parameters

    mbpsOverflow

    The overflow threshold, in megabits per second.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Adds additional bytes to the adapter’s daily data usage limit for today. This value is not added to the base daily data usage limit.

    Declaration

    Swift

    func addAdapterDailyDataLimitBoost(adapterID: String, additionalBytes: Int64)

    Parameters

    adapterID

    ID of the adapterID. i,.e cellular

    additionalBytes

    Additional bytes that may be used today.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Set the data usage, in bytes, allowed on this adapter in a single day. Setting allowedBytes to 0 will disable this limit. Cellular adapters default to 200MB/month.

    Declaration

    Swift

    func setAdapterDailyDataLimit(adapterID: String, allowedBytes: Int64)

    Parameters

    adapterID

    ID of the adapterID. i,.e cellular

    additionalBytes

    Additional bytes that may be used today.

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Set the data usage, in bytes, allowed on this adapter in a single month. 0 for unlimited

    Declaration

    Swift

    func setAdapterMonthlyDataLimit(adapterID: String, allowedBytes: Int64, resetDay: Int64)

    Parameters

    adapterID

    ID of the adapterID.

    additionalBytes

    Additional bytes that may be used today.

    resetDay

    Day of the month that monthly usage is tracked from. 0 for last 30 days. Unused if allowedBytes is 0

    Return Value

    This will show updated information inside of the delegate function func settingsDidUpdate(settings: Settings).

  • Sets the adapter to unlimited daily data usage. Current value available on AdapterData

    Declaration

    Swift

    func disableAdapterDailyDataLimit(adapterID: String)

    Parameters

    adapterID

    ID of the adapterID. i,.e cellular

  • Sets the adapter to unlimited daily data usage. Current value available on AdapterData

    Declaration

    Swift

    func disableAdapterMonthlyDataLimit(adapterID: String)

    Parameters

    adapterID

    ID of the adapterID. i,.e cellular

  • Acknowledge and clear message about a new adapter.

    Declaration

    Swift

    func handleNewAdapter(adapterID: String)

    Parameters

    adapterID

    ID of the adapterID.

  • Set the speed rate limit on a connection.

    Declaration

    Swift

    func setConnectionRateLimit(adapterID: String, bps: Int64)

    Parameters

    adapterId

    Connection to be limited.

    bps

    limit in bps.

  • Will return the last 5 minutes worth of ConnectionStats *Important - This will not return anything on initial connect.

    Declaration

    Swift

    func refreshHistoricalConnectionStats(completionHandler:@escaping (_ message:[ConnectionStatsGroup]?)->Void)
  • Notification on settings change.

    Declaration

    Swift

    func refreshSettings()
  • Set IP address ranges to exclude from going over the VPN tunnel This change takes effect on the next VPN connect. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    func setExcludedIPRanges(excludedRanges: [IPRange])

    Parameters

    excludedRanges
  • Sets the TransportMode selection used for each connection. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    func setConnectionTransportMode(transportMode: TransportMode)

    Parameters

    transportMode
  • Sets whether to allow jumbo packets over the VPN tunnel. Current value available from delegate settingsDidUpdate.

    Declaration

    Swift

    func setJumboPackets(useJumbo: Bool)
  • Undocumented

    Declaration

    Swift

    func refreshState()
  • Refresh account data. Current value available from delegate accountingDataDidUpdate.

    Declaration

    Swift

    func refreshAccounting()
  • Sets how to handle an adapter that has hit its daily or monthly data limit. Current value available on AdapterData objects returned from AdapterUsageData.

    Declaration

    Swift

    func setAdapterOverlimitRatelimit(adapterID: String, bps: Int64)
  • Undocumented

    Declaration

    Swift

    func handleAdapterOverlimit(adapterID: String)
  • Copies logs created by the daemon into the shared App Group Container

    • App Group Capabilities are mandatory when creating logs Please add the following key to the Container and PacketTunnel info.plist NSExtensionFileProviderDocumentGroup YOUR APP GROUP NAME

    Declaration

    Swift

    func generateLogs(completionHandler:@escaping (_ success: Bool)->Void)

    Return Value

    completionHandler: Bool to indicate when the files are ready and copied over.

  • Set IP addresses of the DNS servers to use Current value available from PrivacySettings.

    Declaration

    Swift

    func setDNSServers(_ dnsAddrs: [String])
  • Toggles VPN On Demand.

    When On Demand is on, the operating system will automatically reconnect the VPN whenever internet is available. This setting persists across reboots (so if you set it on, the device will automatically reconnect the VPN after reboot).

    Declaration

    Swift

    func setOnDemand(ondemand: Bool)

    Parameters

    ondemand

    Boolean that toggles the VPN onDemand feature.

  • Undocumented

    Declaration

    Swift

    func setCrashReporting(enable: Bool)
  • Check if the onDemand setting is currently enabled.

    Declaration

    Swift

    func isOnDemandEnabled() -> Bool

    Return Value

    Boolean to determine if onDemand is enabled or disabled.

  • Refresh privacy settings. Triggers privacySettingsDidUpdate

    Declaration

    Swift

    func refreshPrivacySettings()
  • Allows developers to access developer options.

    Declaration

    Swift

    func setDevMode(enabled: Bool)
  • Undocumented

    Declaration

    Swift

    func sessionStatsDidUpdate(stats: SessionStats)
  • Logs out of any current account and logs in to an automatically generated account for this device. If setting a custom directory, call ‘changeDirectoryURL(url: String)’ before calling this. This may take several seconds as the OS is queryied for the device id Login or auto-account creation errors will be signalled in ‘ErrorType’ return in the ‘login(username: String, password: String, completionHandler:@escaping (_ message: State?, _ error: ErrorType)->Void’ closure. Automatic accounts have false email address in the form of .@autoaccount.speedify.com.

    Declaration

    Swift

    func loginAutoAccount()
    • Check if there is already an account using this email address.
    • @since 7.4

    Declaration

    Swift

    func accountCheck(email: String,completionHandler:@escaping (_ error: ErrorType, _ errorMessage: String, _ accountExists: Bool)->Void)
    • Resets the tracked data usage on an adapter.
    • @since future

    Declaration

    Swift

    func resetAdapterUsage(adapterID: String)
    • Create a new account using this email address.
    • @since 7.4

    Declaration

    Swift

    func accountCreate(email: String, password: String, completionHandler:@escaping (_ error: ErrorType, _ errorMessage: String)->Void)
    • Change the password on the account.
    • @since 7.4

    Declaration

    Swift

    func accountPasswordChange(email: String, originalPassword: String, newPassword: String, completionHandler:@escaping (_ error: ErrorType, _ errorMessage: String)->Void)
    • Set ports to be forwarded to this client when connected to a dedicated server.
      • Current value available from ‘SpeedifySettingsDelegate’
    • @since future

    Declaration

    Swift

    func setForwardPorts(ports: [ForwardedPort])

    Parameters

    ports

    Ports to be forwarded

  • This will cancel an auto connect request.

    Declaration

    Swift

    func cancelAutoConnect()
  • Tells the delegate the current ‘State’.

    Declaration

    Swift

    func stateDidUpdate(state: State)
  • Tells the delegate the current ‘AdapterData’.

    Declaration

    Swift

    func adapterDataDidUpdate(adapterData: [AdapterData])
  • Reports any setting error from settings being locked.

    Declaration

    Swift

    func settingLockedError()
  • Tells the delegate the current ‘ConnectionStats’.

    Declaration

    Swift

    func connectionStatsDidUpdate(connectionStats: [ConnectionStats])
  • Tells the delegate the current ‘Settings’.

    Declaration

    Swift

    func settingsDidUpdate(settings: Settings)
  • Tells the delegate the ‘AccountingData’.

    Declaration

    Swift

    func accountingDataDidUpdate(accountingData: AccountingData)
  • Undocumented

    Declaration

    Swift

    func versionDidUpdate(version: Version)
  • Undocumented

    Declaration

    Swift

    func serverInformationDidUpdate(serverInformation: ServerInformation)
  • Undocumented

    Declaration

    Swift

    func torrentUseReported(willDisconnect: Bool)
  • Undocumented

    Declaration

    Swift

    func networkOverLimitUpdated(adapter: String)
  • Undocumented

    Declaration

    Swift

    func privacySettingsDidUpdate(privacy: PrivacySettings)
  • Undocumented

    Declaration

    Swift

    func firewallSettings(settings: FirewallSettings)