An iOS developer's approach to the tvOS SDK

Source: Internet
Author: User
Tags uikit

Http://www.cocoachina.com/ios/20151001/13652.html

Chris Wagner
Original address: TvOS Sdk:an iOS Developer ' s Initial impressions

In the final chapter of Steve Jobs, written by Walter Isaacson, Steve said, "I finally realized and let it have the simplest user interface you can imagine." He was referring to Apple TV at the time.

It's been a long time since Steve died, but people have been looking forward to the product. Just yesterday September 9, 2015, more than four years of anticipation, we finally waited for this gift, although there may be a difference between Steve's vision and ideals of the product? But the pace of revolution has taken a solid step forward.

As an iOS developer, Apple's product launch gave me an emotional surge because Apple announced that the new Apple TV integrates the app Store, which means we can develop proprietary apps for it, and let us rethink what we know about iOS and open up new ideas, Creative opportunities.

Members of me and other tutorial teams have begun to delve into the tvOS SDK and are working to prepare some valuable tvos tutorials (all night!). At the same time, I would like to share with you my initial impressions of tvOS from an iOS developer's perspective.

Let's explore!

Basic concepts
Older Apple TVs are similar to a set-top box, and the main feature is to allow users to navigate or browse video content through their simple interface. The new Apple TV, released yesterday, further expands on this, enabling some mature apps to run on Apple TV, such as shopping apps and even games.

Let's take a look at the following information:

    • Hardware specifications: It's worth saying. Specifications are 64-bit A8 processor, 32G or 64G of storage space, 2G of memory, 1080p resolution and Support Hdmi,siri remote control, The new Apple TV remote.

    • Price: The new Apple TV is priced at 32G $149 and 64G $199. This pricing is far from the majority of people who thought the new Apple TV would be more expensive.

    • Release time: Apple gave a very vague and uncertain release date "Late October" at the press conference, but Apple immediately provided the developer with the tvOS SDK after the launch. It's been a long time from the official sale, and if you have a good idea for the new Apple TV, I suggest you take the moment.

Development hardware: Apple has announced a developer program that allows registered developers to request Apple TV Developer Kit. The program allows developers to test their Apple TV in advance. This may seem like a nice thing to do, but if you really want to join the developer program, take a closer look at the following recommendations:

Note: As is known to all, IOS, OSX developer programs are charged, tvOS's developer program should be no exception, but previously the fee information for the program is very vague, But now we have confirmed in a post from the developer forum by Apple employees that it will only take $1 to join. If you are interested in contributing to tvOS, or if you need to write tutorial materials, you are strongly encouraged to join the development plan.

Developing TvOS applications

After a lot of work, obviously the most important thing is how to develop the application for the new Apple TV, which should be the most interesting thing for everyone!

Developing apps for the new Apple TV is really about developing apps for tvOS, and of course the name tvOS is created by Apple on different devices. tvOS is still based on iOS, so there are a lot of frameworks that everyone should be familiar with.

If you want to develop an application for tvOS, you must download Xcode7.1 for development from the developer Center. This version is the new beta version of Xcode, which currently only supports tvOS and provides tvOS emulators. If you need to, you can also download the Xcode7 GM version, they can coexist in your computer.

Apple offers two ways to develop applications on tvOS:

    • TVML Apps: These applications are developed using a complete new development technology, such as TVML, Tvjs, Tvmlkit. This is a huge surprise for us and we'll have a more detailed introduction later.

    • Custom Apps: These applications are developed using the development techniques we are already familiar with, such as some familiar iOS frameworks, Storyboard, UIKit, Auto layout, and more.

When you're developing apps for Apple TV, you'll see that there are separate program goals in Xcode (which means that users will buy tvOS apps in a separate purchase). While Apple said in the press conference that apps in Apple TV support a common purchase model, which is for apps supported by iOS and tvOS, users can use them on both the iphone and Apple TV at once. But from the current situation, we are not sure how Apple is implemented, perhaps the ability to support two program targets in itunes Connect is coming?

TVML Apps

As I mentioned earlier, there are two ways to develop applications for tvOS, the first of which is through TVML, TVJS, and Tvmlkit technologies. If these abbreviations are very unfamiliar to you, then don't worry, this will tell you what they are:

    • TVML is an XML format based on "television Markup Language".

    • Tvjs is a scripting language based on JavaScript APIs that can show apps based on what is defined in TVML.

    • Tvmlkit is a toolkit for connecting TVML, Tvjs, and native tvOS applications.

If you're a developer who often uses native APIs to develop native iOS apps, then seeing these front-end technologies may be a little daunting. But I hope you can keep a learning heart and learn to understand these new and powerful features.
I'm here to cite a very typical Apple TV application scenario. You can imagine: you want to put some content or information to the user, the content and information stored on your server, and the format of these content, query methods to serve the iphone or ipad applications, you will certainly want your tvos in the application can also be easily used in this content, And to do with the application in iOS similar to the presentation, query, navigation.

If the example I've listed is exactly what your tvOS application needs, you might want to consider how to use the Tvmlkit Toolkit. Apple has done some major work for our developers, such as providing many reusable tvOS interface presentation templates, most of which are similar to the interface of iOS apps, so users are not unfamiliar, and there are about 18 of them. Most templates allow you to create unwound, a very good interface for home TV shows. You can visit Apple's documentation to see the templates that we highly recommend.

I also recommend that you run the TVML Catalog sample app in the tvOS simulator to see each template. At the same time you need to launch a local Web server to make it easy for tvOS apps to show content through templates, so you need to review the readme.md file carefully to find out what's relevant.

Admittedly tvmlkit has a lot of knowledge points, if you want to develop a tvOS application based on it, then some of the documents I mentioned are well worth your reference. Here I would like to highlight the first look at how to use the menu navigation class template, such as Menubartemplate, Maintemplate, searchtemplate and so on. However, if you want users to not just passively watch or listen to content through your tvOS app, but want users to have more interaction with the app and give users a high-quality user experience, then you need to know how to develop a complete custom tvOS application.

Custom Apps

Most iOS frameworks you know, such as Uikit, Core Graphics, Cloudkit, and so on, can be used in tvOS. You can see which frameworks are available and which are not available in this document from Apple. If you're an iOS developer right now, you'll be familiar with the list in this document. And you can develop tvOS applications regardless of whether you use Swift or Objective-c or C. However, if you want to develop a custom tvOS application, there is still a lot of new knowledge that we need to learn, and as an iOS developer, you should also master and even master these new knowledge.

Focus Engine

One of the more unfamiliar concepts for iOS developers is the user input/selection method. In the process of using Apple TV, users do not use their fingers to press or swipe the screen, instead using the remote control provided by Apple or some game controller.

tvOS uses an engine system called focus engine that has and only one in the entire tvos. The engine responds to the selection of menus or content by using gestures or keystrokes on the remote control.

Focus engine automatically determines which view to focus or display based on the user's choice, and you don't need to do anything like check or navigation in your code. For example, the interface shown here is the layout of the view that you have already designed in storyboard, where a view is currently focused, and when the user slides right through the gesture, focus engine automatically finds the adjacent left view and selects and highlights it based on the currently focused view.

As a developer, you have to learn about the API associated with focus engine, such as how to get notifications when a focused view changes, how to trigger a change in the focus view by encoding technician, and so on. More about the Focus engine API can be found in the supporting focus within Your app section of the app Programming Guide for tvOS documentation.

Tvservices

While iOS developers are using some of the more familiar iOS frameworks in the development of tvOS apps, there are some tvos-specific frameworks that require developers to understand, such as the newly added tvservices framework.

The main role of Tvservices is to describe the content of your app so that tvOS is displayed at the top of the home page. The apps that appear at the top of the homepage are set by the user, and users can place the apps they think are most commonly used or most important on the top of the page, allowing them to quickly open or browse the main information.

Your app can provide users with short, interesting information when they're not in the app, which will add value to your app, and using Tvservices is undoubtedly a great way to increase your app downloads. For example, a game application, through tvservices display game archive, then the user can directly from the homepage through the game archive into the game. If it's a social app, you can display social news on the homepage, and if it's a photo-sharing app, you can show recent photos shared by friends and family.

More information about tvservices can be found in the Tvservices Framework reference documentation. Good use of it is very useful for your application.

Parallax Images

There's one more thing that might make you wonder. In the keynote of the conference, Apple highlighted the parallax effects of images and app icons. This is a great view effect, but why is this feature being put in keynote and why is it so important?

If you use the tvOS simulator, you'll see why this feature is so important. When moving the focus view, you need to swipe left or right, but if you just swipe a little, Apple will make a slight rotation of the currently focused view to let the user know that they are doing it (but still need to swipe to change the focus view). This is a detail-oriented but very useful feature.

Apple sees Parallax as a key component of the tvOS design and strongly recommends that the app icon and movie poster use this feature. But thanks to Apple's creating Parallax artwork chapters in the app Programming Guide's for tvOS documentation, we've created a picture resource for parallax, and we've provided a preview app to inspect the image resources.

Controllers
Every user who buys a new Apple TV will receive a powerful new version of the remote control. The previous generation can only choose between the left and right directions and only a few simple navigation keys, while the next generation of Apple TV remote controls add more exciting new features:

    • Glass Trackpad: Located at the top of the remote control, allows the user to perform some gesture actions, such as swiping, tapping, and tapping.

    • Microphone: Allows users to access Siri via the remote control (Siri has the country restrictions) and the voice controls the volume of the TV.

    • Gyroscopes: Combined with motion sensors, they provide a great gaming experience. Users can control the steering wheel in the game by tilting the remote controller to drive, or control the hero to run through the caves.

You can use the API you know to handle gestures to listen for swipe or tap, and some new APIs to listen for different buttons on the remote, such as Pressesbegan (), pressesended (), presseschanged () and pressescancelled ().

The remote control interacts with the Apple TV host via Bluetooth technology, which means that the door is open for the Bluetooth game controller (with all due respect, playing the game with Apple's remote control is not a good choice). Apple has announced that Nimbus SteelSeries Controller will support the new Apple TV. For more information on this, please refer to working with Game Controllers.

TvOS and Games

We sincerely hope that the game will be lit up in tvOS, Apple seems to be directly targeted at Nintendo's indifference to a game market.

tvOS has strong game technology as a support, Spritekit and Scenekit can work properly in tvOS, keynote Crossy developers show their roads game in tvOS, the game uses unity to develop, so
It also implies that tvOS will support unity-developed games in the near future.

Most games developed with Scenekit can be ported seamlessly to the new Apple TV. For example, Ray migrated the zombie conga game introduced in the tutorial to the new Apple TV, taking less than 10 minutes and almost no need to modify any code.

Note: Game videos can be viewed in the original language, but scientific Internet is required.

Limitations

Perhaps two of the current doubts about tvOS are local storage and application size limitations.

Limitation:local Storage
About local storage, the basic certainty is no! If your app needs to persist user data, you need to use icloud, Cloudkit, or your own backup service. Any attempt to present data in Apple TV is not guaranteed to be present the next time the app is opened. If you want to sync data between different settings, you'll need to have the data line somewhere, but not Apple TV.

Be sure to keep this in mind, which is critical for designing the structure of your tvOS application. Some rules are listed here:

    • If the amount of data you need to store is less than 1mb,icloud, the Key-value storage method is a selectable option. Keep in mind, however, that ICloud KVS strictly restricts access to data only to the owner and cannot be shared with other users.

    • If you need to share events or data with other users, Cloudkit is a good choice.

    • If you are developing a cross-platform application or have special needs, you will have to use your own backup service.


Limitation:app Size
Another limitation is the limit on the size of the application, which cannot exceed 200MB.

Before you lift the table, please review the WWDC2015 and the "On-demand Resources" related APIs. It's almost like Apple is laying the groundwork for tvOS early.

These APIs reduce the size of your app's initial installation by downloading resource files on demand. Developers can tag a multimedia resource file in Xcode, and after the app is submitted, the App store automatically splits the multimedia resource file into one download package based on the tag. You can request a resource file to download the tag if you need to use the resource file for a class of tags when the user is using the app. Of course, you have to have the expected judgment, before users use resources to start downloading the resources they need, so that users will not feel that because the download resources to bring bad user experience.

To give a simple example, you have a game app with 10 levels. When a user installs the game, it can contain only two levels of multimedia resource files. Once the user has completed the first level, you should send a download request to download the multimedia resource file for the third level. When the user finishes the second level, the resource files needed for the third level are already ready for download. Throughout the user's game, you can use this mechanism to download the required resource files in step-by-steps.

While this mechanism has undoubtedly increased the workload for developers, it is a very pleasant thing for users. Do you think the user is willing to wait to download a 1GB size game, or more willing to download a 100MB-sized game and start the game immediately. But the mechanism also has a hidden danger, if the user's network conditions are poor, they generally prefer to hang at night to download. So if users play your game during the day and then use the Turtle Speed network to download the resource files behind the level, this is an outrageous user experience. Unfortunately, as a tvos developer, there is nothing to do in this situation.

An iOS developer's approach to the tvOS SDK

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.