Month: June 2015

In this post I want to show you the first look at Apple Watch. This post includes: pairing the watch with your iPhone, the charger and what happens when the watch is disconnected from the paired iPhone.

My experience is that the Apple Watch is a cool gadget to wear, but I ended up using the phone for everything and the watch only to see the time. The Apple Watch is not really good to check the time, since the screen turns on automatically when you do the movement with your wrist. There are sometimes that I don’t do this movement, or that the watch does not detect it. In these cases, you have to touch the screen with your finger. Anyway the wrist movement detection works really good.

These are the specifications of the Apple Watch that I have used for this post:

The following image shows the box containing the Apple Watch. Two watch bands with different sizes are included.

Pairing the Apple Watch

You need your Apple Watch (of course) and the companion Apple Watch app on your iPhone.The companion Apple Watch app is available since iOS version 8.2. First make sure that you have updated your device to iOS 8.2 or later. You should see the following Apple Watch icon on your device.

Once you turn on your Apple Watch, it will ask you to set it up and pair it with your iPhone.
Open the Apple Watch app on your iPhone and follow the steps of the setup assistant. Finally press the “Start Pairing” button on your watch.

Both the watch and the phone display a screen indicating the syncing process.

When the syncing is finished, you’re ready to go!

Charging the Apple Watch

The charger is a magnetic charging cable. You only need to place your watch on the charger.

When the battery level of the Apple Watch is very low, around 10%, the power reserve mode is started automatically. You can also start this mode in any moment from the Power glance or from the power off menu.
While in the power reserve mode, you can only see the time on the screen along with an icon showing the red battery level icon. The watch doesn’t react to your finger touch and you need to press the physical side button to see the time.
The following left image shows the watch with low power level. The right image shows the watch while charging.

Disconnected from your iPhone

The Apple Watch needs your iPhone to support most of its features. If the watch can’t communicate with your phone, a red icon is displayed on the top part of the screen as shown in the following image.

When the phone is out of range, some apps won’t work on the watch.
As shown in the next left image, a red message warns the user that the data was last updated some days ago. The red icon indicating that the phone is not in range is displayed on the top right corner of the watch screen. The right image shows an application with no data at all.

In this post I want to show you how we can create the simplest iOS app that monitors and ranges devices that follow the iBeacon protocol. An iBeacon device is a BLE (Bluetooth Low Energy) device that transmits its identification information: UUID, major and minor.
You can learn more about iBeacon in this previous post here.

Project setup

Create a new empty project in XCode. You can select the Single View Application template.

Enable the permissions needed to use the Core Location services. To do this, add the following two properties in the .plist file of your app:

NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription.

Here is an example of these two properties:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is needed to monitor Beacons in range</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is needed to monitor Beacons in range</string>

My Location Manager

Create the class that will manage all the beacon events: MyLocationManager.

Import the CoreLocation library in the .h file of your new class:

#import <CoreLocation/CoreLocation.h>

The MyLocationManager class is going to implement the CLLocationManagerDelegate protocol to receive the beacon events:

@interface MyLocationManager : NSObject <CLLocationManagerDelegate>

The MyLocationManager class also needs two methods so the app can start/stop monitoring iBeacons. Add these methods to the interface:

- (void)startMonitoringUUID:(NSString *)uuid;
- (void)stop;

Monitoring iBeacons

Open the implementation .m file of our MyLocationManager class and add a private property to keep an instance of the iOS system CLLocationManager class.

Line 3. Create an object of the CLLocationManager class.
Line 4. Set our MyLocationManager object as its delegate.
Line 7-8. Request permission.
Line 10-12. Create a region with the UUID received as parameter.
Line 14. Start monitoring for the recently created region.

Implement the delegate method to receive the iBeacon events. For this small sample app, iBeacon events are just printed to the app log:

Ranging iBeacons

Add the code to start ranging. A good approach is to start ranging once it has been detected that the user is inside a region. This code is added in the locationManager:didDetermineState:forRegion method: