Posted on Leave a comment

How to implement UI state restoration

People naturally multitask on their devices. Whether they’re switching from app to app, bringing together apps on iPad using Slide Over or Split View, or creating multiple windows of the same app, they should be able to pick up right where they left off — and UI state restoration is a core part of making that experience seamless.

When your app goes out of view, the app’s process is typically put on pause; it’s not given any more CPU time, which keeps the processor free for other tasks. If your app has background processes that are running, the system can even terminate those if an active app needs more resources than currently available.

Restoring the state of your UI is a crucial part of making your app feel responsive — and it’s especially important if you plan to support multiple windows in your iPadOS app. If you have a note-taking app that has four different notes open in different Split View pairings, for example, state restoration helps preserve each note, rather than returning someone to the main screen when they open one of the windows.

Two different types of scenes can be backgrounded and processes halted. These scenes’ states should be saved to restore later.

Meet NSUserActivity

NSUserActivity is a core part of modern state restoration with UIScene and UISceneDelegate: It provides a lightweight way to capture the state of your app and put it to use later, holding key information for both view controllers and important view states — information that can also be used when constructing view controllers for Handoff and Universal Linking.

While what you store in NSUserActivity is up to you, we recommend collecting only the bare minimum so that your app can quickly restore itself. Think of the most unique and simple way you can identify your view controller, like a clear identifier or URL. Include that information, and make sure you can identify where the view controller lives in your navigation and how content should appear within it. For example, when using an Xcode storyboard you may want to store and retrieve view controllers using restoration IDs.

Get started with UI state restoration

The best way to implement UI state restoration is to make your app scene-based, which requires iOS 13, iPadOS 13, Mac Catalyst 10.13, or tvOS 13 or later. (For more information on working with scenes in your app, check out the Developer Library.) Here’s how to get started with scene-based state restoration:

  1. Create a NSUserActivity object to save the app’s state. This can be created in your scene delegate.
  2. In this NSUserActivity, store relevant information (like the current navigation’s state, and view controllers that have been presented or pushed) along with your user’s intent.
  3. Return this NSUserActivity within stateRestorationActivity(for:) in the scene delegate.

You need to collect the right information in each UIScene to pick up where someone left off.

This NSUserActivity will now be stored inside the scene’s stateRestorationActivity property. When your app needs to restore its state, it should do so by looking for this saved NSUserActivity under scene(_:willConnectTo:options:) in the scene delegate.

What about the older view controller-based state restoration APIs?

If you need to support older versions of iOS, macOS, or tvOS, you can use older view controller-based APIs for state restoration via restoration classes and the app delegate. This also means if you want to update your app to adopt UIScene as well as implement UI state restoration across multiple versions of iOS, you will need to implement both scene-based and view-controller based APIs. However, we highly recommend building scene-based UI state restoration.

Compared to the older APIs, modern state restoration requires a different approach to how you define, save, and restore your UI state and your user’s intent. With a scene-based app, you have to separate events in an application’s life cycle and the scene’s life cycle, which means tracking changes also differs. Having multiple scenes means there are many more windows to track, each with unique user actions and navigation history. For some of those windows, you may choose not to restore state depending on their function, requiring state restoration to be more flexible and dependent on how you define the user’s intent.

Prior to the introduction of UIScene, each app had a singular life cycle.

If you can update your app to scene-based restoration and take advantage of NSUserActivity, you’ll also unlock easier pathways to implementing features like Spotlight search, Handoff, enabling Universal Links, and creating new scenes as primary or auxiliary windows. And you’ll provide a smoother and frictionless experience for people using your app, too.


Resources

Watch “Architecting your app for multiple windows”

Watch “Targeting content with multiple windows”

Watch “Window management in your multitasking app”

Learn more about restoring state in non-scene based apps

Explore sample code for restoring your app’s state

Posted on Leave a comment

The App Store Expands to 20 New Countries

You can now distribute your apps in 175 countries and regions on the App Store, allowing you to increase your impact and grow your business. As you deliver great experiences to an even more diverse audience, learn how you can localize your apps, product pages, and marketing materials to better connect with customers in different locations.

As a reminder, to allow your app to appear in these new countries, your membership Account Holder first needs to accept the updated Program License Agreement by signing in to their account on the Apple Developer website. If you have a Paid Applications Agreement, the Account Holder will also need to accept this updated agreement in App Store Connect. To make your app automatically available in all new countries, select the “New Countries or Regions” checkbox.

View your account

Learn about expanding to new markets

Posted on Leave a comment

Updated Guidelines for HealthKit

HealthKit allows your app to provide valuable health-related insights to users by working with the Apple Health app. The updated HealthKit Human Interface Guidelines include guidance on using the Apple Health icon in your app, enhanced editorial guidance on using Apple Health-related terms, and clarified privacy and data-usage guidelines.

View Human Interface Guidelines

Works with Apple Health badge now available. You can also now use the Works with Apple Health badge to promote your HealthKit-enabled apps. Download the badge and review the guidelines for using the badge on marketing communications.

Learn about the badge

Posted on Leave a comment

Meet the developer: Brian Mueller

Brian Mueller can make anything hilarious. Even the weather.

Brian Mueller is something of a Renaissance man. He single-handedly codes, designs, illustrates, and writes all of the dialogue for his wisecracking Carrot apps, which fall into categories that typically don’t have a lot of personality: to-do lists, alarm clocks, calorie counters.

To call his style droll would be an understatement. The exercise app Carrot Fit, for instance, implores you to “jump flabby human, jump for freedom!” in a deadpan robotic voice.


For more about Brian Mueller and his approach, check out this video interview where he details Carrot Weather’s evolution on Apple Watch.


Each Carrot app delivers surprising punch lines.

Carrot To-Do is equally sardonic — “It’s been 18 hours since you did anything useful” — while Carrot Weather takes liberties with its forecasts. “It’s a beautiful day! Ha ha, just kidding. It’s raining.”

A smack-talking to-do list app might not seem like the big idea that would let you quit your day job. In fact, Carrot’s success caught even Mueller off guard. “For some reason, people have responded to this. I still can’t believe sometimes any of this caught on,” he says.

Working out of a spare room in his Philadelphia-area home, the former aspiring screenwriter has penned thousands of lines of dialogue for his apps, which he constantly updates to nod to current events. (A recent one-liner from Carrot Weather: “Don’t tell anyone, but I regularly send bad weather to areas with high concentrations of stay-at-home order protesters.”)

Mueller is a one-man team, making half a dozen apps from home.

As for the inspiration for Carrot, Mueller credits those closest to him: his mom, sister, and wife — all of whom tease one another relentlessly.

“A lot of the dialogue for Carrot is drawn out of stuff that we’ve actually said to each other,” he says. “Every time my wife says something funny, I write it down for the apps. Sometimes she gets annoyed by that, but she’s a lot funnier than I am.”

Brian Mueller’s wife, Greta, is one of Carrot’s biggest inspirations.

When Mueller dreamed up the idea to create a character-driven app, he had zero coding experience. “I’m an English major with a creative-writing minor. I love to write and create characters and tell stories, but I had no real idea of what I would do with my life.”

Mueller’s first instinct was to hire a developer to realize his vision. “I didn’t want to sound like a jerk when talking to a programmer, so I bought a book on iOS programming for beginners, just to know what terms to use,” he says. As he read iOS Programming: The Big Nerd Ranch Guide, Mueller was surprised by how easy it is to make an app. By January 2013, Carrot To-Do had launched on the App Store. It took him about a month to create.

I love to write and create characters and tell stories, but I had no real idea of what I would do with my life.

Brian Mueller, Carrot creator

Initially, sales were tepid. It took a couple of years, and a few more apps, before Carrot found a broad-enough audience for Mueller to quit his day job and become a full-time developer.

The Carrot universe continues to expand. Mueller has built seven iOS apps and an iOS sticker pack, as well as Apple Watch, Apple TV, and Mac versions of Carrot Weather. With the arrival of AR (augmented reality) technologies on iOS, Mueller taught himself how to add an AR component to Carrot Weather. Now you can see the surly character Carrot as a spherical “ocular sensor” hovering in your surroundings. She turns red if you annoy her.

Watch Carrot float around your world in Carrot Weather’s AR mode.

Although being a one-man app shop isn’t easy, Mueller enjoys wearing all the hats. “When I hit a road block with coding, I can take a break and switch to writing or doing some design work,” he says. “I’m not stuck doing the same thing over and over.

“It’s a weird way to work, but I’m a bit of a perfectionist and it allows me to make exactly what I want.”

Originally published on the App Store.

Posted on Leave a comment

Upcoming price and tax changes in Barbados, Malaysia, Moldova, and Uzbekistan

When taxes or foreign exchange rates change, we sometimes need to update prices on the App Store. In the next few days, prices of apps on the App Store and in-app purchases (excluding auto-renewable subscriptions) will change in Barbados, Moldova, and Uzbekistan due to new value-added taxes. Your proceeds will be adjusted accordingly and will be calculated based on the tax-exclusive price.

A low value-added tax was also introduced in Malaysia. Prices on the App Store in Malaysia will not change and proceeds will be adjusted accordingly.

You can download the updated price tier charts now. Once these changes go into effect, the Pricing and Availability section of My Apps will be updated. You can change the price of your apps and in-app purchases (including auto-renewable subscriptions) at any time in App Store Connect. If you offer subscriptions, you can choose to preserve prices for existing subscribers.

View updated price tiers

Posted on Leave a comment

Meet the developer: Catana Chetwynd

For fans of Catana Comics, her sticker app was love at first sight.

Thanksgiving with her boyfriend’s parents, a bout of the flu, and a “very old” iPad. These were the circumstances that gave rise to Catana Chetwynd’s beloved cartoons back in 2016, when she was 21 years old.

“I had been playing around with drawing on the iPad for a few months and John [now her fiancé] suggested that I make a comic,” she says. “It seemed like a good way to pass the time, since I wasn’t feeling well. Turns out, it was really fun!”

Over the next few days, she drew five more comics based on everyday situations in her relationship, like not-so-subtly requesting back rubs from John and rolling her eyes at his juvenile jokes.

John and Catana: the real-life couple behind the cartoons.

John, a software engineer, posted them on Reddit, and the internet fell hard: more than 2,000 comments poured in.

“We were really surprised by the flood of positive responses,” Chetwynd says. John set up a website and she created an Instagram account—which now has nearly 3 million followers—and Catana Comics was born.

“There are some incredibly awesome webcomics out there,” Chetwynd says, “but when we started, there weren’t really any based on a couple.” She has found that most of her fans enjoy sharing her comics with a significant other.

How Catana Comics go from sketch to screen.

It makes sense, then, that the number-one request Chetwynd got from her followers was for a sticker pack. With the Catana Comics iMessage app, fans can easily exchange her big-eyed, huge-hearted caricatures with a special someone.

“Shortly after we came out with the first batch of stickers,” Chetwynd says, “I received an email from a woman who said that her husband was on a very long business trip in a different time zone. She loved that the stickers allowed them to quickly send emotive messages without using words.”

Fans demanded stickers—and here they are.

Chetwynd can relate, since she and John connect via her stickers too: “We both work from home, but in different rooms, and there are so many days where the only communication we’ll have is sending each other a sticker every hour or so.”

One of her go-tos: a drawing of John looking at a picture of her saying, “I miss you.”

“It was in the very first release and I wasn’t thinking it could be funny when I made it, but now John will go to the bathroom and I’ll send it to him,” she says. “I use it almost every day.”

Originally published on the App Store.

Posted on Leave a comment

How to support Route Guidance in CarPlay Dashboard

CarPlay Dashboard consolidates music, maps, and Siri suggestions into a single screen inside your car for a safer, smarter experience. Starting with iOS 13.4, you can add support for CarPlay Dashboard in your navigation app, too: Make your map, upcoming maneuvers, and dashboard buttons available at a glance by adopting a few new capabilities inside the CarPlay framework.

Note: To integrate your app with CarPlay Dashboard, your CarPlay navigation app needs to support UIScene. For more information on adopting UIScene, check out “Introducing Multiple Windows on iPad”.

Get started with CarPlay Dashboard

To support CarPlay Dashboard inside your navigation app, you’ll need to update to Xcode 11.4 if you haven’t already.

iOS 13.4 offers new capabilities within the CarPlay framework: CPDashboardButton, CPDashboardController, and CPTemplateApplicationDashboardScene.

CPTemplateApplicationDashboardScene is a new UIScene subclass that CarPlay creates when it determines that your app should appear in CarPlay Dashboard.

CPDashboardController and CPDashboardButton let you manage controls that appear in CarPlay Dashboard.

How to add support for CarPlay Dashboard

To take advantage of CarPlay Dashboard, start by supporting CPTemplateApplicationDashboardScene and its related protocol CPTemplateApplicationSceneDelegate.

Note: You need use CPTemplateApplicationSceneDelegate instead of CPApplicationDelegate to support this feature.

We’ll take you through each step below. In addition, we’ve provided a sample application scene manifest for your reference.

<key>UIApplicationSceneManifest</key>
<dict> <key>CPSupportsDashboardNavigationScene</key> <true/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneClassName</key> <string>UIWindowScene</string> <key>UISceneConfigurationName</key> <string>Phone</string> <key>UISceneDelegateClassName</key> <string>MyAppWindowSceneDelegate</string> </dict> </array> <key>CPTemplateApplicationSceneSessionRoleApplication</key> <array> <dict> <key>UISceneClassName</key> <string>CPTemplateApplicationScene</string> <key>UISceneConfigurationName</key> <string>CarPlay</string> <key>UISceneDelegateClassName</key> <string>MyAppCarPlaySceneDelegate</string> </dict> </array> <key>CPTemplateApplicationDashboardSceneSessionRoleApplication</key> <array> <dict> <key>UISceneClassName</key> <string>CPTemplateDashboardScene</string> <key>UISceneConfigurationName</key> <string>CarPlay-Dashboard</string> <key>UISceneDelegateClassName</key> <string>MyAppCarPlayDashboardSceneDelegate</string> </dict> </array> </dict>
</dict>

Step 1: Create a scene delegate

To begin, define a scene delegate for CPTemplateApplicationSceneSessionRoleApplication. This can be done dynamically in your UIApplicationDelegate by returning a configuration in application:configurationForConnectingSceneSession:options:, or ahead of time in your app’s Info.plist in the Application Scene Manifest.

The delegate must conform to CPTemplateApplicationSceneDelegate, where it will be given an instance of CPInterfaceController and CPWindow, as you’ve been used to with CPApplicationDelegate.

Additionally, to support CPTemplateApplicationDashboardScene, include a new key in your Application Scene Manifest to declare support for CarPlay Dashboard: CPSupportsDashboardNavigationScene with a value of true.

Step 2: Define the dashboard delegate

Next define your delegate to the dashboard scene just like you would for the main template application scene. This delegate conforms to CPTemplateApplicationDashboardSceneDelegate and will be given an instance of CPDashboardController and UIWindow.

Step 3: Draw your CarPlay Dashboard content

Use the provided window to draw navigation related content for display in the CarPlay Dashboard, similar to the CPWindow given to the main template application scene. You can also provide two instances of CPDashboardButton to CPDashboardController that appear in the guidance card widget while your app is not actively navigating.

Step 4: Use your app in CarPlay Dashboard

People can interact with your app through both the dashboard buttons as well as within your main app interface. When navigation begins in your app using CPMapTemplate and CPNavigationSession, CarPlay will automatically display maneuvers in the guidance widget. When navigation ends, it will revert to your currently set dashboard buttons.


Resources

Learn more about creating apps for CarPlay

Learn more about integrating CarPlay with your navigation app in the Developer Library

Posted on Leave a comment

How to scan and analyze surroundings with the LiDAR Scanner on iPad Pro

ARKit 3.5 can take advantage of the LiDAR Scanner on the iPad Pro 11-inch (2nd generation) and iPad Pro 12.9-inch (4th generation) to help your apps better understand physical environments.

Learn how your apps can use information from the cameras and LiDAR Scanner to analyze the real world, get depth information, and form 3D meshes that:

  • Accurately locate points on physical surfaces
  • Recognize and classify physical objects
  • Occlude virtual objects with real-world objects
  • Enable realistic interactions between virtual and physical objects

For example, An AR game might use mesh generated by Scene Geometry, which uses information from the LiDAR Scanner, to let someone realistically bounce a virtual ball off a physical wall inside their room.

Learn more and explore a sample app in the Developer Library

Posted on Leave a comment

New Financial Report Coming to App Store Connect

Starting April 2020, you can get more details on the final proceeds of your apps and in-app purchases, including the transaction and settlement dates for purchases, as well as the state or province for transactions in the United States and Canada. Simply download the “All Countries or Regions (Detailed)” report in App Store Connect.

View App Store Connect Help

Posted on Leave a comment

Meet the developer: Rich Siegel

Why BBEdit creator Rich Siegel has always put the user above all.

BBEdit may be one of the most beloved developer tools on any platform, but its creator, Rich Siegel, had relatively modest ambitions. He started writing the first version of the software back in 1989 because he needed an editor that could handle “large” files—something north of 32 KB.

“One of the limitations of Macintosh Pascal was that source files couldn’t be more than 32 kilobytes,” he explains.

Over a quarter century has passed since BBEdit’s commercial debut, and the app has become a favorite among developers, scientists, web designers, and writers alike for its sheer power and speed. (Siegel regularly tests 12 GB files these days.)

Siegel remains BBEdit’s principal architect and lead engineer, and the caffeine molecule tattooed on his arm says a lot about his work ethic. We spoke with him from his Bare Bones Software headquarters north of Boston, which Siegel shares with a pair of African gray parrots.


Developers, do you have an interesting story to tell? The App Store‘s editorial team would love to hear it!


What were the early days of BBEdit like?

Back then, the way to put Mac software out in the world was to submit it to the Info-Mac Archive, an FTP repository hosted by Stanford. So that’s what I did, and word started to spread pretty fast online.

I had mentioned that if anyone wanted a copy on disk, they could mail a floppy and a self-addressed return envelope to me at my home. I was inundated with floppies.

BBEdit has been around for a lifetime by software standards. How have you seen the user base change?

Our base started as Mac software developers, scientists, system administrators, and other technical users. The first big change was popularity among HTML authors and web back-end developers. As word spread, we were able to help folks understand that the internet was built with text—that you could treat text as data or you could treat it as a document. So the next wave brought in internet architects, cryptanalysts, and scientists from unexpected disciplines.

The third wave has been mostly writers and other content creators—folks who see their text not as data but as words, and who want as little as possible between them and their words.

However, as many changes as we’ve seen, there has been a delightful constancy to our customers: They’re people who simply want to get work done. They’re not distracted by shiny things in their software tools.

What are some of the more surprising projects you’ve seen people create with BBEdit?

There’s been so much! Our customers have used BBEdit to create novels, doctoral theses, and other long written works. One customer has used BBEdit as part of the development workflow to fly UAVs [unmanned aerial vehicles] the size of an F-16; the flight control system sends data to BBEdit in real time, where the engineers examine it, change it, and send it back to the aircraft in just a few seconds. And the Human Genome Project even uses BBEdit to help analyze long sequences of DNA.

Version 3.0 of BBEdit, “accelerated for Power Macintosh,” from 1994.

How has the software evolved over the years?

BBEdit has undergone one huge technical transformation after another. First there was the port to PowerPC. We developed an OpenDoc component, and some of the internal architecture work we did for that is still in use.

Then came a nearly complete rewrite of its internal architecture, followed closely by a port to Mac OS X—BBEdit was the first third-party application to run natively on that new OS—and then the port to Intel. Last year we finished rewriting BBEdit again, this time as an AppKit application.

In between PowerPC and OpenDoc, there was another development: the emergence of the World Wide Web. BBEdit had a plug-in model at the time, and two of our customers—one in the UK and one in Spain—independently wrote HTML markup tools. This was 1995, and we had no idea what HTML was, but we could tell that it was going somewhere. So we evaluated the tools, chose a set of them to bundle with BBEdit, and off we went. Little did we know…

BBEdit is one of the most beloved apps out there. Why do you think that is?

We’ve always had the utmost respect for the user. Every internal decision about look and function answers the questions “What does the customer need?” and “How can we help them be more productive?” (Not “How can we give them what they’re asking for?” because that isn’t the right question to answer.) The Macintosh was introduced to help anybody do great things. It’s something we believe in completely.

Originally published on the Mac App Store.