Apple Watch Kit SDK Tutorials

  • Sonar Systems admin
    Likes 0

    Problem Description

    With the recent boom of Wearable devices more specifically Apple Watch, we need to know how to make apps for those devices and that is exactly what this series is for.

    Solution Description

    List of planned tutorials:

    1. Hello World (Setting Up) – recommended you have a strong foundation in Objective-C/Swift and iOS/Xcode development
    2. Setting Up A Static Notification
      1. Create new scheme
      2. Explain Static and Dynamic
        1. Static – stock notifications that only can use data from the APNS file
        2. Dynamic – notifications that can get data from outside the APNS file so from the app itself based on what user does
      3. Required items
        1. Label
        2. Dismiss button
        3. Time
        4. Icon and title
    3. Setting Up A Dynamic Notification
      1. Create new scheme
      2. Add label to interface for dynamic notification
      3. Code for accessing label 
        1. Show NSLog(@“”);
        2. @property (weak, nonatomic) IBOutlet WKInterfaceLabel* label;
        3. Drag label onto it from the interface
        4. [self.label setText:@"Text Label"];
    4. Code Logic
      1. Add button
      2. Add label
      3. Add items to code by dragging
      4. When button is clicked change text
    5. Glance
      1. Provides some basic information to the user at a glance, when clicked the user is taken to the Apple Watch app.
    6. Text Input
      1. Add a button to the interface
        1. Link button to code to create a method
      2. Code for text input
        1. NSArray *textItems; // add to the header
        2. textItems = [NSArray arrayWithObjects:@"Sonar", @"Systems", @"Duff", @"YH", nil]; // add to the awakeWithContext method
        3. [self presentTextInputControllerWithSuggestions:textItems allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) { NSLog(@"%@", results.firstObject); }]; // add to the button pressed method
    7. Context Menus
      1. Add Menu onto interface
        1. Add Menu Items onto the Menu Item (maximum of 4)
      2. Link Menu Item to code to create a method
      3. Add logic inside the newly created method
    8. Sharing Data Between Watch and Device
      1. Add group to device and watch target capability
      2. Add button to the device
        1. Link button to code to create a method
        2. NSUserDefaults *mySharedDefaults = [[NSUserDefaults alloc] initWithSuiteName: @"group.sonarsystems"];
        3. [mySharedDefaults setValue:@"Batman" forKey:@"sharedKey"];
        4. [mySharedDefaults synchronize];
      3. Log data from watch awakeWithContext method
        1. NSUserDefaults *mySharedDefaults = [[NSUserDefaults alloc] initWithSuiteName: @"group.sonarsystems"];
        2. NSLog(@"%@", [mySharedDefaults valueForKey:@"sharedKey"]);
    9. HTTP Request
      1. Add button and label onto interface
        1. Connect label and button to the code
      2. NSURLRequest *url = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ip.jsontest.com/"]];
        NSURLResponse *responseReceived = nil;
        NSError *errorReceived = nil;
        NSData *data = [NSURLConnection sendSynchronousRequest:url returningResponse:&responseReceived error:&errorReceived];
        NSMutableDictionary *allData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&errorReceived];
        NSString *ip = allData[@"ip"];
        self.label1.text = ip;
    10. MapKit
      1. Add Map object onto interface
        1. Connect map to the code
      2. #import 

         

      3. CLLocationCoordinate2D coordinates;
        coordinates.latitude = 51;
        coordinates.longitude = -0.3;
        MKCoordinateSpan span;
        span.latitudeDelta = 0.35;
        span.longitudeDelta = 0.35;
        MKCoordinateRegion region;
        region.center = coordinates;
        region.span = span;
        [[self mapView] setRegion:region];

         

    11. Animation (credit it to Ravin Sardal, images from him as well http://bit.ly/1GqE9tD)
      1. Add image object onto interface
        1. Connect image to the code
      2. Add images to project
      3. [[self imageView] setImageNamed:@"wheel-"];
        [[self imageView] startAnimatingWithImagesInRange:NSMakeRange(0, 5) duration:0.25 repeatCount:0];

         

    Resources used:

    http://www.raywenderlich.com/89562/watchkit-tutorial-with-swift-getting-started

    https://www.youtube.com/watch?v=WHZplO3kIjE&list=PLPXQAmNk2rv1XXVfJY4g1rpPXtxPVyNt2&index=4

    https://www.youtube.com/watch?v=J4A-AYLGOcE&list=PLveAIogCrRlX2KIm8rfytPArufhV9knnV&index=10

    http://natashatherobot.com/watchkit-actionable-notifications/


  • aaka14
    Likes 0

    Matkaplay.center is the optimum place for online matka play and also for online kalyan matka. Our platform provides you with the best interface & also with superfast results to make huge points and cash online, with all hassle free processes. Follow your best skills in 500 or 100 deposit matka play and earn a decent amount of money with us, just you have to open online matka play account and winning points would be automatically added into it.

Login to reply