Apple Watch battery life

One of the key factors to the adoption of wearables is their battery life.

We already use laptops, smartphones and tablets that we need to charge almost everyday. Having a wearable device like a smartwatch implies one more device to charge. If our smartphone has a low battery level, we can find a place to charge it while we do some other things. With a smartwatch we need to take it off. We can’t check the time while it is charging, at least not just by looking at our wrist.

Battery life is an important feature that we should consider when choosing a smartwatch, so I have measured the battery drain of the Apple Watch. In this post I want to show the results.

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

Apple Watch Sport
Height: 42.0mm
Width: 35.9mm
Depth: 10.5mm
Case: 30g
White color.

Battery drain

I analyzed the battery drain of the Apple Watch doing a very basic use of it.

This means that I checked the time once in a while and I read some notifications. Nothing more. I didn’t spend time exploring apps from the watch, I didn’t use the maps nor I monitored any type of exercise.
The results indicate that the battery life of the Apple Watch is around 50 hours: a little more than 2 days.
Therefore if you do more actions with the Apple Watch than just simply checking the time or reading notifications, the battery life will be less than 2 days, which means you need to charge it everyday.

The following chart shows the battery drain over time.

Battery chart

Power reserve

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.

Low power
Apple Watch no battery

When the Apple Watch is in power reserve, the battery drain is much lower. This can be observed in the next chart, where the power reserve mode was enabled during some hours.

Battery level with power reserve

More results

Apple Watch charging
Charging time 
It takes around 120 minutes to charge the Apple Watch completely, that is around 2 hours.

Boot time 
It takes around 1 minute and 10 seconds to boot the Apple Watch.

Read More

First look at Apple Watch

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:

Apple Watch Sport
Height: 42.0mm
Width: 35.9mm
Depth: 10.5mm
Case: 30g
White color.

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

 

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.

Apple Watch app icon

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.

Apple Watch start pairing

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

Apple Watch pairing

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

Apple Watch ready
Apple Watch apps

 

Charging the Apple Watch

The charger is a magnetic charging cable. You only need to place your watch on the charger.
Apple Watch 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.

Apple Watch no battery
Apple Watch 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.

Apple Watch out of range

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.

Apple Watch weather
Apple Watch stock

 

This post has explained the first steps when using your Apple Watch. If you want to learn more, check my future posts and here is the link to the Apple Watch User Guide.

Read More

iBeacon Sample Project

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.

The complete xcode project that is explained in this post can be downloaded from my public github repository here.


Project setup

  1. Create a new empty project in XCode. You can select the Single View Application template.
  2. 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

  1. Create the class that will manage all the beacon events: MyLocationManager.
  2. Import the CoreLocation library in the .h file of your new class:
    #import <CoreLocation/CoreLocation.h>
  3. The MyLocationManager class is going to implement the CLLocationManagerDelegate protocol to receive the beacon events:
    @interface MyLocationManager : NSObject <CLLocationManagerDelegate>
  4. 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

  1. Open the implementation .m file of our MyLocationManager class and add a private property to keep an instance of the iOS system CLLocationManager class.
    @interface MyLocationManager ()
    @property (strong,nonatomic) CLLocationManager *locationManager;
    @end
    
  2. Implement the start method.
    - (void)startMonitoringUUID:(NSString *)uuid
    {
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
    
        // Request permission (mandatory iOS8 + info.plist)
        if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
            [self.locationManager requestAlwaysAuthorization];
    
        CLBeaconRegion *region = [[CLBeaconRegion alloc]
           initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:uuid]
           identifier: uuid];
    
        [self.locationManager startMonitoringForRegion:region];
    }
    

    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.

  3. Implement the delegate method to receive the iBeacon events. For this small sample app, iBeacon events are just printed to the app log:
    - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
    {
        switch (state) {
            case CLRegionStateInside:
                NSLog(@"locationManager didDetermineState INSIDE for %@", region.identifier);
                break;
    
            case CLRegionStateOutside:
                NSLog(@"locationManager didDetermineState OUTSIDE for %@", region.identifier);
                break;
    
            default:
                NSLog(@"locationManager didDetermineState OTHER for %@", region.identifier);
        }
    }
    
  4. Finally implement the stop method:
    - (void)stop
    {
        for(id region in self.locationManager.monitoredRegions) {
            [self.locationManager stopMonitoringForRegion:region];
        }
    }
    

Ranging iBeacons

  1. 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:
    - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
    {
        switch (state) {
            case CLRegionStateInside:
                NSLog(@"locationManager didDetermineState INSIDE for %@", region.identifier);
                [self.locationManager startRangingBeaconsInRegion:(CLBeaconRegion*)region];
                break;
    
            case CLRegionStateOutside:
                NSLog(@"locationManager didDetermineState OUTSIDE for %@", region.identifier);
                break;
    
            default:
                NSLog(@"locationManager didDetermineState OTHER for %@", region.identifier);
        }
    }
    
  2. Add the code to stop ranging. A good approach is to stop ranging when it is detected that the user is outside a region. This code is added in the locationManager:didDetermineState:forRegion method:
    - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
    {
        switch (state) {
            case CLRegionStateInside:
                NSLog(@"locationManager didDetermineState INSIDE for %@", region.identifier);
                [self.locationManager startRangingBeaconsInRegion:(CLBeaconRegion*)region];
                break;
    
            case CLRegionStateOutside:
                NSLog(@"locationManager didDetermineState OUTSIDE for %@", region.identifier);
                [self.locationManager stopRangingBeaconsInRegion:(CLBeaconRegion*)region];
                break;
    
            default:
                NSLog(@"locationManager didDetermineState OTHER for %@", region.identifier);
        }
    }
    
  3. Finally implement the delegate method to receive the iBeacon ranging events. These ranging events are just printed to the app log:
    - (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
    {
        if(beacons != nil && (0 < beacons.count)) {
            for(CLBeacon *b in beacons) {
                NSLog(@"%@/%@ %ld", b.major, b.minor, b.proximity);
            }
        }
    }
    

The complete xcode project that has been explained in this post can be downloaded from my public github repository here.

Read More

Introduction to iBeacon

The iBeacon standard is an extension of iOS Location Services. An iBeacon device is a BLE (Bluetooth Low Energy) device that transmits its identification information: UUID, major and minor. This information is hierarchical and the UUID is the beacon’s principal identifier.
The iBeacon functionality provided by iOS allows two types of actions:

  • Region Monitoring. Notifies when the user has entered the specified region.
  • Beacon Ranging. Determines the estimated proximity to the beacons in range: Immediate, Near, Far or Unknown.

A Region in iBeacon terms is a network of iBeacons defined by a shared identifier. A region can be specified by its UUID, major and minor. Major and minor identifiers are optional for a region, but the UUID is necessary.

iOS limits to 20 the number of regions that may be simultaneously monitored by a single app.

For example, if only the UUID is specified for a region, all the iBeacons with that UUID will be considered part of that region.

Beacons inside a UUID region

If we specify the UUID and also a major value for the region, then only the iBeacons with that UUID and major are considered as part of that region.

Beacons inside a UUID+major region

Once a region has been detected, the details of the iBeacons in range inside that region are obtained by ranging, not by monitoring.

Background detection

While the app is running in the foreground it can range to determine the signal strength between the iBeacons and the device. This ranging process is not allowed while the app is not running in the foreground. Only monitoring is allowed while the app is in the background/not running.
Region monitoring is capable of waking the app up from running in the background/not running when the app enters or exits the region. These are the only triggers that will wake the app from running the background/not running: entering or exiting a region. Once the app is awoken it can run for ~10 seconds if closed completely and ~2 minutes if it is running in the background.

Core Location Framework

iBeacon APIs are available in the Core Location Framework. The central point of this framework is the CLLocationManager class. An instance of this class is necessary to start/stop the location services, to configure them, and to receive the related events.
The CLLocationManager reference can be found here.

Read More

Swipe gestures in a UITableView

When we have a UITableView, sometimes we want to add some actions when the user swipes over a row of the table. We can capture swipes to the left, right, down or up directions.
To capture both left and right swipe gestures, add the following code to your UITableViewController in the viewDidLoad method.

UISwipeGestureRecognizer *gestureLeft = [[UISwipeGestureRecognizer alloc] 
     initWithTarget:self 
     action:@selector(handleSwipeLeft:)];
[gestureLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.tableView addGestureRecognizer:gestureLeft];
    
UISwipeGestureRecognizer *gestureRight = [[UISwipeGestureRecognizer alloc] 
     initWithTarget:self 
     action:@selector(handleSwipeRight:)];
[gestureRight setDelegate:self];
[gestureRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.tableView addGestureRecognizer:gestureRight];

The action parameter indicates the method that will be executed when the gesture is recognized. We have to include these methods in our controller too.


- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    
    // Action...
}

- (void)handleSwipeRight:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    
    // Action...
}

The method locationInView returns the location of the gesture, represented as a point in the local coordinate system of the view. Using the indexPathForRowAtPoint method of the UITableView object, we can obtain the row of the gesture.

We could use also the same action method to handle all the swipe gestures. Change the action methods from handleSwipeLeft and handleSwipeRight to handleSwipe, and add the following method instead.

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
    CGPoint point = [gestureRecognizer locationInView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];

    switch ([gestureRecognizer direction]) {
        case UISwipeGestureRecognizerDirectionLeft:
            // Action
            break;
        case UISwipeGestureRecognizerDirectionRight:
            // Action
            break;
        default:
            break;
    }
}

Read More

Location Manager in iOS 8

The Core Location service in iOS 8 includes now two different modes of authorization: While Using the App and Always.

Location permissions

In our code application we must request the user to accept one of these modes.

  • When In Use. This mode allows your app to use the location services when the app is in the foreground.
    if([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
       [self.locationManager requestWhenInUseAuthorization];
    
  • Always. This mode allows your app to use the location services when the app is in the foreground and in the background.
    if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
       [self.locationManager requestAlwaysAuthorization];
    

Finally, we have to add in the Info.plist file of our app the values for the keys NSLocationWhenInUseUsageDescription or/and NSLocationAlwaysUsageDescription. These values contain the messages that will be displayed to the user when requesting the authorization.

info.plist properties

Read More

Create a git repository from an existing XCode project

The following steps can be followed to create a Git repository from an existing XCode project.

  1. Open the terminal and navigate to the directory containing your XCode project.
  2. Execute the following commands to create a local Git repository:
    > git init
    > git add .
  3. Open your project using XCode.
  4. Navigate to the menu “Source control” > “your project” > “Configure”.
  5.  Open the “Remotes” tab as shown in the following screenshot.
    git step 3
  6. Click on the + button.
  7. Add the remote repository indicating its remote address.
    git step 4
    git step 4 b
  8. Now that the remote repository has been configured, we can commit the project. Navigate to “Source control” > “Commit”. You can check the “Push to remote” option or we can do it in two different steps. Click on the Commit button.
    git step 5
  9. Push the local commit to the remote repository. Navigate to “Source control” > “Push”.
    git step 6
    git step 6 b

Read More

Seguridad y Privacidad en Carpetas Personales de Salud para Android e iOS

For my PhD I write scientific articles that are submitted to scientific journals or conferences. The objective is to get them accepted and published. Currently we have 3 papers accepted. One of them has recently been published, the only article written in Spanish. The journal is Iberian Journal of Information and Technologies.

The RISTI (Iberian Journal of Information Systems and Technologies) is a peer-reviewed scientific journal, published by Academy Publisher in association with AISTI (Iberian Association of Systems and Information Technology), which focuses the research and the innovative practical application in the field of information systems and technologies. It is a biannual journal that publishes original and innovative articles accepted in an evaluation process by, at least, three members of the Scientific Council.

The journal is published in electronic and print version. The electronic version is free access and here is the reference (APA style) and the link to my article:

Zapata, B., Niñirola, A., Fernández-Alemán, J., & Toval, A. (2014). Seguridad y Privacidad en Carpetas Personales de Salud para Android e iOS. Iberian Journal Of Information Systems And Technologies, 0(13), 35-50. doi:10.4304/risti.13.35-50

RISTI nº 13

The abstract of the article:

Durante los últimos años, el uso de dispositivos móviles como teléfonos inteligentes y tabletas ha suscitado gran interés entre los proveedores de servicios de salud en el mundo de la mSalud. Las Carpetas Personales de Salud (en inglés Personal Health Record o PHR) móviles proporcionan numerosas ventajas y aunque hay estudios que indican que los pacientes están dispuestos a utilizarlos, los índices de uso son aún bajos. La seguridad y la privacidad han sido identificadas como una importante barrera para lograr su amplia adopción. Haciendo uso de un método adaptado de la revisión sistemática de literatura se identificaron 24 PHRs móviles para Android e iOS. La seguridad y privacidad de estos PHRs móviles fueron evaluadas usando un cuestionario de 12 preguntas. Nuestra investigación muestra que los desarrolladores de PHRs móviles han de mejorar sustancialmente sus políticas de privacidad.

 

Read More

Passbook: Type ID and certificate

Related posts about Passbook:


In order to create passes and allow them to be recognized by Passbook, they have to be signed with a valid certificate. The certificate is associated to a specific type of pass, so we need to create a Pass Type ID and a certificate for each kind of pass we want to support.

To create a Pass Type ID, log in into your developer account, navigate to your member center and to the Certificates, Identifiers & Profiles page. In the identifiers section, select the Pass Type IDs option. From this page the passbook Type IDs are listed and we can edit them, delete them or create a new one. Click on the plus icon button to create a new ID. Type a description and type the ID which has to start with the “pass.” string.

Register iOS Pass Type ID

Follow the next steps and the ID registration will be completed. The new ID should appear in the Pass Type IDs list.

To create the Pass Type ID Certificate, open the Production page from the Certificates section and click on the plus icon button to create a new one. Check the Pass Type ID Certificate option and click on the Continue button. In the next page we have to select the ID created before. Click on the Continue button.

iOS certificate of the Pass ID

Finally we have to upload our Certificate Signing Request file (.certSigningRequest). This request file can be obtained from the Keychain of a MacOS computer, but probably you already generated it when you created your app or created other certificates. Upload this request file, click on the Generate button and then we willl be able to download the certificate by clicking the Download button. The downloaded certificate is a .cer file.

Download Pass certificate

Read More

Best apps to learn a language

When we want to learn a new language, it is a common thing to search for our own resources. These resources can be books or online sites with lessons, podcasts and exercises. A good alternative is to use mobile applications, even better if you can use a tablet.

Currently I am learning French and I am using mobile applications myself, so I have written a post about the ones I consider the most useful.

1. Duolingo

iPhone Screenshot 2iPhone Screenshot 3

iPhone Screenshot 4

Web page http://www.duolingo.com/
Web version Yes
Devices iPhone/iPad, Android
Languages Spanish, French, Italian, Portuguese, German, English
Price Free
Internet connection Necessary to open a lesson different from your current level

Being totally free, this app provides a variety of exercises that work on all the necessary areas: writing, listening, speaking… It is good for learning vocabulary and grammar, because all the exercises are based on sentences, so both of them are presented together, making it easy to learn.

What I like the most is the translation and listening exercises, in which you have to write whole sentences by translating the original or listening to it. This is more difficult and instructive than just choosing the correct answer from some possible options, like most of apps do.

Your progress is displayed as a nice hierarchy of levels and when it’s been a long time since you last used the app, you will have to do some refresher exercises.

2. MindSnacks

Captura de pantalla del iPhone 1

Captura de pantalla del iPhone 2

Captura de pantalla del iPhone 5

Web page http://www.mindsnacks.com/
Web version No
Devices iPhone/iPad
Languages An app for each language: Spanish, French, Italian, Portuguese, German, Chinese, Japanese.
Price Free but in-app costs to get all the lessons: 4.49€
Internet connection Not necessary

This app is perfect to learn vocabulary. By playing games we can study the vocabulary and have fun with it. To make it more addictive, there are also challenges to get extra points and level up. A disadvantage is not having an app for Android.

What I like the most is that you can play the games using the vocabulary from all the lessons (or just some of them) at the same time, so they are not limited to a specific level, like most of apps do. This functionality is the best way to refresh the vocabulary.

3. Busuu

iPhone Screenshot 3

iPhone Screenshot 4

iPhone Screenshot 2

Web page http://www.busuu.com
Web version Yes
Devices iPhone/iPad, Android
Languages An app for each language: Spanish, French, Italian, Portuguese, German, English, Chinese, Japanese, Russian, Polish, Turkish
Price Free but in-app costs to get all the levels: 4.49€ each level. Full course: 14.99€
Internet connection Necessary to do some types of exercises

This app is the most expensive but it have a lot of different lessons with different types of exercises. In comparation to the other two apps, this app is not so good at making you memorize the vocabulary. The exercises consist on choosing the correct option from the proposed ones. There is not listening exercises and the writing exercises are corrected by the people from the bussu community.

What I like the most is the text comprehension exercise in which a text is displayed, audio included, and we have to answer questions about it. The other advantage of this app is that the language offer is wider.

Read More