Senior iOS Developer at Master of Code Global discusses application development for Apple Watch and the second version of WatchOS.
Is there a big difference in approach to iOS and WatchOS development?
There are no substantial differences. The only thing worth considering is a limited functionality that iOS developer can use when programming for WatchOS 2. Basically, any iOS developer can switch to WatchOS and implement all the necessary functionality using Object-C or Swift.
Read also: Top Programming Languages 2017
What can you develop for Apple Watch?
- Watch Apps – used to display full information.
- Glance – allows users to view important information from the application for the time being (it can be compared with a widget on phones).
- Notifications – Apple watch takes full advantage of the existing online notification support on iOS.
What does the development of Watch App look like?
The development of native applications for Apple watch can be divided into three blocks:
- UI interface
- Connection between the phone and the watch:
- work directly with the database(Core data);
- ikeness socket development in terms of WCSession.
- Development of action logic on the Apple Watch.
Have you been developing a native app?Do you think that the second version has been improved?
Yes, we had to develop a native application for the Apple Watch, and I may say that the functionality on WatchOS 2 is much wider than on WatchOS 1.0. A common feature of the WatchOS 1.0 applications is that their code is executed on the phone, and the app for watches contains only the user interface fil es. As a result, the application is not native, and looks like a phone widget. Now WatchOS 2 is a separate application that has more ways to customize the user interface, and has its own storage space for images and other information. This allows the application to be more independent from the phone and have a better performance initially. You can also connect to the phone database, which improves the synchronization between devices.
What snarks or bugs have you encountered during the process of developing?
WatchOS 2 still is not perfect and has many bugs, such as:
- if there is a request from the watch to the phone, and there is no connection or it is cut off, the screen darkens and a loader appears. However, you cannot take any action. The only way out is to press the button “Home”;
- when switching fast between screens, there is a risk of breaking the navigation;
- in case there is a large number of applications installed on the watch, one can notice a default text while a modal window is loading;
- when the application is removed from the phone, it may remain on the watch;
- when an application is updated via crashlytics, it cannot be updated on the watch, and as a result a crash occurs or this application just does not start;
- if the phone returns NULL for some property then the clock crashes.
With the release of 2.2 version we expect that there would be more bugs related to the fact that one phone can be connected to a large number of watches. What I’ve found great here is that in comparison with a phone (where it’s quite complicated) you may easily change the design for different sizes of watch screens.
Is there any difference which Apple Watch to test on (with different memory capacity, for example)?
All versions of Apple Watch have 8GB of memory, the operating system allows the user to store up to 2GB of music and 75 MB of photos and that is enough for all. What is important here is to test on various versions of iOS. For example, not only version 9.x, but on 8.x. In this case, there is a good chance the functionality will not work. Another aspect that worries iOS developers – we can not transmit to the watch objects that do not have any values (NSNull), as it may serve as a crash for application. Unfortunately, crashlytics can not track crash on watches and the debugging process itself is inconvenient for the programmer.
Got a project idea? Let’s talk business
How important are the device characteristics in conjunction with iPhone – Watch? Including hardware and the version?
Device characteristics do not affect the iPhone – Watch communication. What only matters is the version of the operating system on the devices, since it can contribute to certain restrictions in functionality. Designed as an application under WatchOS 2 it cannot be installed on a younger version. You will see a message box that the phone can not install the application. In this case, there is a choice: to develop an application once for both versions WatchOS or only for the newest one. But, as practice shows, the customer selects the adaptation to the latest version.
What can you customize, and what you can’t?
There are native elements and we cannot make drastic changes. You can change the color, font, size and position, but it’s possible to customize only in a limited range. With version 2.2 expansion of the font base is planned. At the Watch app it is not possible to put one element over another. For example, we cannot put the text above the picture. Either you must set the background of the whole canvas, and then put those components on the background that you need. Alignment of the components is divided into two types: horizontal and vertical, which complicates the UI interface design. We should think it over in advance, what are the components, which groups they belong to and how to combine them so that they coincide with the design that the client has. Apple allows to customize radically only the default applications, for example Watch Face can be changed in the settings on the device.
How does the synchronization between the iPhone and the Watch take place, if there was an update on the phone?
There are two ways of data synchronization:
- Session (pseudosocket) which in turn is divided into:
- text messaging – such sockets have a limit, that we may share no more than 1 kb of data at a time, because while transferring large volumes of data the notification comes that you need to go to another type;
- file transfer – there are no restrictions, but we hold the band, which can lead to the iPhone and Watch mistiming.
- Application context. Exchange takes place in the background and timeliness of the data can not be guaranteed, but it provides data storage to show at the start of the application.
May the application operate autonomously without a phone?
Only for static information. There occurs a synchronization after connection to the phone. Theoretically, at WatchOS 2 it can be realised, but it is better not to risk and wait. Today it is not the best approach, watches are designed to expand the functionality of your phone, but not to replace it.
So there would be no merit in watch without the phone, except the watch itself?
If you have Apple Watch version 1.0, then the answer is yes. In the new version, everything depends on the developers and how they have implemented the application for watches.
Why watch connects only to iPhone, but not to iPad?
On the phone there is a special program (Watch), which is responsible for the watch connection, for tracking, adding and removing programs . iPads do not have it. Most likely, Apple doesn’t see any need in it.
Read also: Mobile App Development Trends 2017
What’s the problem of modal windows on the watch and what challenges does it create for app design?
We can not go to another screen (deeper in the hierarchy) from the modal window . It’s possible to make it via software, but then at the next window, the transition will not happen when you click on the Cancel button. Therefore, at the design stage, it is necessary to analyze all the navigation having that in mind. But on the Internet there are already some blanks that help to realize the transfer function through the screens in any direction. Another goal that client has given us is the transition in a modal window to the page N. It is possible in the modal window to realise page navigation (Page View), but there is no method to jump to any page. To achieve this, we have created a controller which sequentially shifts from the page N to the page N+1 until we reach the right one.
Is it possible to access the watch sensors from the app? For example, gyroscope or pulsometer?
In WatchOS this is not possible. For example, to access the pulsometer you need to contact the HealthKit framework that goes with WatchOS. For other sensors there are appropriate frameworks.
What happens to the application when the watch cannot communicate with the iPhone?
If it was envisaged at the design stage by the programmer, the watch can simply show a message that there is no connection, and at the status bar will appear the corresponding icon. If this is not done, the application will simply hang up and crash or you will see a loader. From the phone party it is not as critical, but there may be a data mistiming.
Might there be some database on the watch?
There is no relational database, but it can apply directly to the phone database. It is possible to store intermediate data in text format, but you need to describe the logic of your work.
Can you highlight any features of notifications on the Apple Watch?
Notification function is probably one of the features of the watch. But there is one point to remember – the watch will receive the notification only when your phone is locked. Otherwise, the notification will always be displayed only on the iPhone. Notifications can come not only from the server but also from the phone.
Are there any restrictions you should be aware of concerning the animations for WatchOS applications?
The restrictions are that you can change position, size, color and font of the buttons and labels, while all other animations have to be implemented through a set of images.
Were there any differences when you published the app in the App Store ?
The procedure of publishing is the same, you only need to download screenshots for device on iTunes Connect and that is all.
Also published on Medium.