Documentation Archive Developer
Search

WatchConnectivity Changes for Swift

WatchConnectivity

Declaration
From
enum WCErrorCode : Int {
    case GenericError
    case SessionNotSupported
    case SessionMissingDelegate
    case SessionNotActivated
    case DeviceNotPaired
    case WatchAppNotInstalled
    case NotReachable
    case InvalidParameter
    case PayloadTooLarge
    case PayloadUnsupportedTypes
    case MessageReplyFailed
    case MessageReplyTimedOut
    case FileAccessDenied
    case DeliveryFailed
    case InsufficientSpace
}
To
enum WCErrorCode : Int {
    case GenericError
    case SessionNotSupported
    case SessionMissingDelegate
    case SessionNotActivated
    case DeviceNotPaired
    case WatchAppNotInstalled
    case NotReachable
    case InvalidParameter
    case PayloadTooLarge
    case PayloadUnsupportedTypes
    case MessageReplyFailed
    case MessageReplyTimedOut
    case FileAccessDenied
    case DeliveryFailed
    case InsufficientSpace
    case SessionInactive
    case TransferTimedOut
}

Modified WCSession
Declaration
From
class WCSession : NSObject {
    class func isSupported() -> Bool
    class func defaultSession() -> WCSession
    init()
    weak var delegate: WCSessionDelegate?
    func activateSession()
    var paired: Bool { get }
    var watchAppInstalled: Bool { get }
    var complicationEnabled: Bool { get }
    var watchDirectoryURL: NSURL? { get }
    var reachable: Bool { get }
    var iOSDeviceNeedsUnlockAfterRebootForReachability: Bool { get }
    func sendMessage(_ message: [String : AnyObject], replyHandler replyHandler: (([String : AnyObject]) -> Void)?, errorHandler errorHandler: ((NSError) -> Void)?)
    func sendMessageData(_ data: NSData, replyHandler replyHandler: ((NSData) -> Void)?, errorHandler errorHandler: ((NSError) -> Void)?)
    var applicationContext: [String : AnyObject] { get }
    func updateApplicationContext(_ applicationContext: [String : AnyObject]) throws
    var receivedApplicationContext: [String : AnyObject] { get }
    func transferUserInfo(_ userInfo: [String : AnyObject]) -> WCSessionUserInfoTransfer
    func transferCurrentComplicationUserInfo(_ userInfo: [String : AnyObject]) -> WCSessionUserInfoTransfer
    var outstandingUserInfoTransfers: [WCSessionUserInfoTransfer] { get }
    func transferFile(_ file: NSURL, metadata metadata: [String : AnyObject]?) -> WCSessionFileTransfer
    var outstandingFileTransfers: [WCSessionFileTransfer] { get }
}
To
class WCSession : NSObject {
    class func isSupported() -> Bool
    class func defaultSession() -> WCSession
    init()
    weak var delegate: WCSessionDelegate?
    func activateSession()
    var activationState: WCSessionActivationState { get }
    var paired: Bool { get }
    var watchAppInstalled: Bool { get }
    var complicationEnabled: Bool { get }
    var watchDirectoryURL: NSURL? { get }
    var reachable: Bool { get }
    var iOSDeviceNeedsUnlockAfterRebootForReachability: Bool { get }
    func sendMessage(_ message: [String : AnyObject], replyHandler replyHandler: (([String : AnyObject]) -> Void)?, errorHandler errorHandler: ((NSError) -> Void)?)
    func sendMessageData(_ data: NSData, replyHandler replyHandler: ((NSData) -> Void)?, errorHandler errorHandler: ((NSError) -> Void)?)
    var applicationContext: [String : AnyObject] { get }
    func updateApplicationContext(_ applicationContext: [String : AnyObject]) throws
    var receivedApplicationContext: [String : AnyObject] { get }
    func transferUserInfo(_ userInfo: [String : AnyObject]) -> WCSessionUserInfoTransfer
    func transferCurrentComplicationUserInfo(_ userInfo: [String : AnyObject]) -> WCSessionUserInfoTransfer
    var outstandingUserInfoTransfers: [WCSessionUserInfoTransfer] { get }
    func transferFile(_ file: NSURL, metadata metadata: [String : AnyObject]?) -> WCSessionFileTransfer
    var outstandingFileTransfers: [WCSessionFileTransfer] { get }
}

Declaration
From
protocol WCSessionDelegate : NSObjectProtocol {
    optional func sessionWatchStateDidChange(_ session: WCSession)
    optional func sessionReachabilityDidChange(_ session: WCSession)
    optional func session(_ session: WCSession, didReceiveMessage message: [String : AnyObject])
    optional func session(_ session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler replyHandler: ([String : AnyObject]) -> Void)
    optional func session(_ session: WCSession, didReceiveMessageData messageData: NSData)
    optional func session(_ session: WCSession, didReceiveMessageData messageData: NSData, replyHandler replyHandler: (NSData) -> Void)
    optional func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject])
    optional func session(_ session: WCSession, didFinishUserInfoTransfer userInfoTransfer: WCSessionUserInfoTransfer, error error: NSError?)
    optional func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject])
    optional func session(_ session: WCSession, didFinishFileTransfer fileTransfer: WCSessionFileTransfer, error error: NSError?)
    optional func session(_ session: WCSession, didReceiveFile file: WCSessionFile)
}
To
protocol WCSessionDelegate : NSObjectProtocol {
    optional func session(_ session: WCSession, activationDidCompleteWithState activationState: WCSessionActivationState, error error: NSError?)
    optional func sessionDidBecomeInactive(_ session: WCSession)
    optional func sessionDidDeactivate(_ session: WCSession)
    optional func sessionWatchStateDidChange(_ session: WCSession)
    optional func sessionReachabilityDidChange(_ session: WCSession)
    optional func session(_ session: WCSession, didReceiveMessage message: [String : AnyObject])
    optional func session(_ session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler replyHandler: ([String : AnyObject]) -> Void)
    optional func session(_ session: WCSession, didReceiveMessageData messageData: NSData)
    optional func session(_ session: WCSession, didReceiveMessageData messageData: NSData, replyHandler replyHandler: (NSData) -> Void)
    optional func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject])
    optional func session(_ session: WCSession, didFinishUserInfoTransfer userInfoTransfer: WCSessionUserInfoTransfer, error error: NSError?)
    optional func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject])
    optional func session(_ session: WCSession, didFinishFileTransfer fileTransfer: WCSessionFileTransfer, error error: NSError?)
    optional func session(_ session: WCSession, didReceiveFile file: WCSessionFile)
}