wkinterfacemap on apple watch

18
WKInterfaceMap on Apple Watch trippiece Inc. @kitasuke

Upload: yusuke-kita

Post on 28-Jul-2015

928 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: WKInterfaceMap on Apple Watch

WKInterfaceMap on Apple Watchtrippiece Inc.@kitasuke

Page 2: WKInterfaceMap on Apple Watch

Restaurant finder appin Shibuya

Page 4: WKInterfaceMap on Apple Watch

There are limitations on WKInterfaceMap

at this time

Page 5: WKInterfaceMap on Apple Watch

Current limitations• Request location access on iPhone, not Apple Watch

• Not scrollable on map

• Not zoomable on map

• Not opening Apple's map app

• 5 annotations at maximum

Page 6: WKInterfaceMap on Apple Watch

Location servicevar locationManager = CLLocationManager()

override init() { super.init()

locationManager.delegate = self if CLLocationManager.locationServicesEnabled() { switch CLLocationManager.authorizationStatus() { case .AuthorizedAlways, .AuthorizedWhenInUse: locationManager.startUpdatingLocation() } }}

func locationManager(manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) {

}

Page 7: WKInterfaceMap on Apple Watch

Use Handoff in case it's not granted yet

override init() { let type = "com.example.com" let userInfo = ["actionID": 1] self.updateUserActivity(type, userInfo: userInfo, webpageURL: nil)}

Page 8: WKInterfaceMap on Apple Watch

AnnotationNo annotation for current locationUse custom image instead

Page 9: WKInterfaceMap on Apple Watch

CacheCache annotation imageslet image = UIImage()let device = WKInterfaceDevice.currentDevice()device.addCachedImage(image, name: "annotation")

self.mapView.addAnnotation(CLLocationCoordinate2DMake(0.0, 0.0)withImageNamed:"annotation"centerOffset:CGPointZero)

Page 10: WKInterfaceMap on Apple Watch

RealmRealm is a replacement for SQLite & Core Data. It can save you thousands of lines of code & weeks of work, and lets you craft amazing new user experiences.

Page 11: WKInterfaceMap on Apple Watch

Why Realm?

Page 12: WKInterfaceMap on Apple Watch

Usage between iOS and WatchKit// Get the shared directory for the application grouplet id = "group.com.example.my-app"let fileManager = NSFileManager.defaultManager()let container = fileManager.containerURLForSecurityApplicationGroupIdentifier(id)

// Set the default realm path to a location in the shared containerlet fileName = "defualt.realm"if let realmURL = container?.URLByAppendingPathComponent(fileName) { RLMRealm.setDefaultRealmPath(realmURL.path)}

// Get location infolet restaurant = Restaurant.allObjects().firstObject() as! Restaurantlet coordinate = CLLocationCoordinate2DMake(restaurant.latitude, restaurant.longitude)

Page 13: WKInterfaceMap on Apple Watch

App reviewWe found that the usefulness of your Apple Watch app is limited by the minimal features it includes. Specifically, your Apple Watch app only launches out to Maps.— From Apple

Page 14: WKInterfaceMap on Apple Watch

There are tons of functions, but make it

simple

Page 15: WKInterfaceMap on Apple Watch
Page 16: WKInterfaceMap on Apple Watch

 PagingMenuItem  SegmentedControl

Page 17: WKInterfaceMap on Apple Watch

Usagelet viewController = UIViewController()viewController.title = "Menu title"let viewControllers = [viewController]

let options = PagingMenuOptions()options.menuHeight = 50

let pagingMenuController = self.childViewControllers.first as! PagingMenuControllerpagingMenuController.setup(viewControllers: viewControllers, options: options)

Page 18: WKInterfaceMap on Apple Watch

Welcome your feedbackhttps://github.com/kitasuke/PagingMenuController