1 #import <KeychainCircle/KeychainCircle.h>
3 #if !TARGET_OS_SIMULATOR
4 #import <MobileKeyBag/MobileKeyBag.h>
5 #endif /* !TARGET_OS_SIMULATOR */
7 #import "OTPairingSession.h"
9 @interface OTPairingSession ()
10 @property (readwrite) NSString *identifier;
11 @property (readwrite) KCPairingChannel *channel;
14 @implementation OTPairingSession
16 - (instancetype)initWithDeviceInfo:(OTDeviceInformationActualAdapter *)deviceInfo
18 return [self initWithDeviceInfo:deviceInfo identifier:[[NSUUID UUID] UUIDString]];
21 - (instancetype)initWithDeviceInfo:(OTDeviceInformationActualAdapter *)deviceInfo identifier:(NSString *)identifier
23 KCPairingChannelContext *channelContext = nil;
25 if ((self = [super init])) {
26 self.identifier = identifier;
28 channelContext = [KCPairingChannelContext new];
29 channelContext.uniqueClientID = [NSUUID UUID].UUIDString;
30 channelContext.uniqueDeviceID = [NSUUID UUID].UUIDString;
31 channelContext.intent = KCPairingIntent_Type_SilentRepair;
32 channelContext.model = deviceInfo.modelID;
33 channelContext.osVersion = deviceInfo.osVersion;
36 self.channel = [KCPairingChannel pairingChannelInitiator:channelContext];
38 self.channel = [KCPairingChannel pairingChannelAcceptor:channelContext];
46 #if !TARGET_OS_SIMULATOR
47 if (self.lockAssertion) {
48 CFRelease(self.lockAssertion);
49 self.lockAssertion = NULL;
51 #endif /* !TARGET_OS_SIMULATOR */