TKInterAppCommunicator
@objc
public class TKInterAppCommunicator : NSObject
Undocumented
-
Undocumented
Declaration
Swift
@objc(sharedInstance) public static let shared: TKInterAppCommunicator
-
Will be called if the user selects an action that requires opening a website. By default just opens the webpage in Safari.
Declaration
Swift
public var openURLHandler: @MainActor (URL, String, UIViewController) -> Void
-
Undocumented
Declaration
Swift
public var openStoreHandler: @MainActor (Int, UIViewController) -> Void
-
Undocumented
See moreDeclaration
Swift
public enum ExternalActionType
-
Undocumented
See moreDeclaration
Swift
public struct ExternalAction : Equatable
-
Undocumented
Declaration
Swift
public func registerExternalActionHandlers(_ handlers: [TKInterAppExternalActionHandler])
-
Checks if the communication can handle any of the segment’s available external actions, which depends both on whether there’s a relevant handler registered for it and whether the device is capable, too.
Declaration
Swift
@objc(canHandleExternalActions:) public func canHandleExternalActions(for segment: TKSegment) -> Bool
Parameters
segment
A segment
Return Value
Whether the action can be handled, i.e., triggering
handleExternalActions
will succeed. -
Checks if the communication can handle the provided action, which depends both on whether there’s a relevant handler registered for it and whether the device is capable, too.
Declaration
Swift
public func canHandleExternalAction(_ action: String) -> Bool
Parameters
action
An action string, as defined by SkedGo’s backend
Return Value
Whether the action can be handled, i.e., triggering
performExternalAction
will succeed. -
Determines external actions for the provided segment
Declaration
Swift
public func externalActions(for segment: TKSegment) -> [ExternalAction]
Parameters
segment
A segment
Return Value
Available actions, can be empty
-
This will handle the external actions of the specified segments either by launching the external app (if there’s only one action) or by presenting a sheet of actions to take for the user.
Declaration
Swift
@MainActor @objc(handleExternalActions:presenter:initiatedBy:completionHandler:) public func handleExternalActions(for segment: TKSegment, presenter: UIViewController, sender: Any?, completion: ((String) -> Void)?)
Parameters
segment
A segment for which
canHandleExternalActions
returnstrue
presenter
A controller to present the optional action sheet on
sender
An optional sender on which to anchor the optional action sheet
completion
Called when any action is triggered.
-
This will perform the provided external action, taking information from the (optionally) provided segment
Declaration
Swift
@MainActor @objc(performExternalAction:forSegment:presenter:initiatedBy:) public func performExternalAction(_ action: String, for segment: TKSegment?, presenter: UIViewController, sender: Any?)
Parameters
action
An action for which
canHandleExternalAction
returnstrue
segment
Optional segment for things like start/end locations to pass to a turn-by-turn app
presenter
A controller to present the optional action sheet on
sender
An optional sender on which to anchor views as required by the handler
-
This will perform the provided external action, taking information from the (optionally) provided segment
Declaration
Swift
@MainActor public func perform(_ action: ExternalAction, for segment: TKSegment?, presenter: UIViewController, sender: Any?)
Parameters
action
An action for which
canHandleExternalAction
returnstrue
segment
Optional segment for things like start/end locations to pass to a turn-by-turn app
presenter
A controller to present the optional action sheet on
sender
An optional sender on which to anchor views as required by the handler
-
Undocumented
Declaration
Swift
@objc(canOpenInMapsApp:) public static func canOpenInMapsApp(_ segment: TKSegment) -> Bool
-
Opens the segment in a maps app. Either directly in Apple Maps if nothing else is installed, or it will prompt for using Google Maps or Waze.
Warning
Checking for Google Maps and Waze only works the appropriate URL schemes are added to theLSApplicationQueriesSchemes
of your app’sInfo.plist
:<key>LSApplicationQueriesSchemes</key> <array> <string>comgooglemaps-x-callback</string> <string>waze</string> ... </array>
Declaration
Swift
@objc(openSegmentInMapsApp:forViewController:initiatedBy:currentLocationHandler:) public static func openSegmentInMapsApp( _ segment: TKSegment, forViewController controller: UIViewController, initiatedBy sender: Any, currentLocationHandler: ((TKSegment) -> Bool)? )
Parameters
segment
A segment for which
canOpenInMapsApp
returnstrue
controller
A controller to present the optional action sheet on
sender
A controller to present the optional action sheet on
currentLocationHandler
Will be called to check if turn-by-turn navigation should start at the current location or at the segment’s start location. If
nil
it will start at the current location.
-
Undocumented
Declaration
Swift
public static func openMapsApp( in mode: TKTurnByTurnMode, routeFrom origin: MKAnnotation?, to destination: MKAnnotation, viewController controller: UIViewController, initiatedBy sender: Any? )