| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#import "ViewController.h" |
| 5 |
|
| 6 |
@interface ViewController () <WCSessionDelegate> |
| 7 |
|
| 8 |
@end |
| 9 |
|
| 10 |
@implementation ViewController |
| 11 |
|
| 12 |
- (void)session:(WCSession *)session activationDidCompleteWithState:(WCSessionActivationState)activationState error:(NSError *)error { |
| 13 |
|
| 14 |
} |
| 15 |
|
| 16 |
- (void)sessionDidBecomeInactive:(WCSession *)session { |
| 17 |
|
| 18 |
} |
| 19 |
|
| 20 |
- (void)sessionDidDeactivate:(WCSession *)session { |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
- (void)viewDidLoad { |
| 25 |
[super viewDidLoad]; |
| 26 |
// Do any additional setup after loading the view, typically from a nib. |
| 27 |
|
| 28 |
if ([WCSession isSupported]) { |
| 29 |
WCSession *session = [WCSession defaultSession]; |
| 30 |
session.delegate = self; |
| 31 |
[session activateSession]; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
- (IBAction)applyButtonClicked:(id)sender { |
| 36 |
if ([[WCSession defaultSession] isReachable]) { |
| 37 |
NSDictionary *dictionary = @{ |
| 38 |
@"host" : [self.hostNameTextField text], |
| 39 |
@"port" : [self.portTextField text] |
| 40 |
}; |
| 41 |
|
| 42 |
[[WCSession defaultSession] sendMessage:dictionary |
| 43 |
replyHandler:^(NSDictionary *replyHandler) {} |
| 44 |
errorHandler:^(NSError *error) {}]; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
@end |