How to Pause and Resume Your App’s Audio in Response to Turn-by-Turn Notifications and Other Audio from Other Apps
I’m writing this down if only so I can reference it myself later. Maybe this will help you, dear reader in some not-too-distant future. If you are making an iOS app that plays spoken-word audio (like, say, a podcast app) and you want your audio to pause when another app plays some audio (turn-by-turn directions notifications, etc.), then here is the TL;DR of what you need to do:
Your app’s audio session should use an appropriate category, most likely:
AVAudioSessionCategoryPlayback.Your app’s audio session should use the
AVAudioSessionModeSpokenAudiomode, which signals to AVFoundation that your audio session is primarily spoken word content which should ideally be interrupted by certain categories of audio from other apps’ audio sessions.Your app should register for the
.AVAudioSessionInterruptionnotification (contrary to the documentation, don’t assume it’s fired on the main queue - be safe). In your handler for the notification, first check the user info to see whether the value forAVAudioSessionInterruptionTypeKeyis.beganor.ended. If it’s.began, then your audio player is likely already paused. You should update any other model or UI state accordingly. If the state is.ended, then you should check the value forAVAudioSessionInterruptionOptionsto see if it contains.shouldResume. If it does, you should resume playback. AVFoundation will not resume playback on your behalf.
Sadly, even if you do all these things, the final result is partially out of your control. The other app that triggered the interruption must configure its audio session with the option:
AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers
which signifies that it should mix with other audio sessions besides spoken audio, which should be interrupted. Apple’s Maps app does this. Google Maps does not. 😞
For more information, read this programming guide.
The Value of Grey Thinking
This idea should be taught as part of a standard college, or even high school, curriculum:
But the fact is, reality is all grey area. All of it. There are very few black and white answers and no solutions without second-order consequences.
This fundamental truth is easy to grasp in theory and hard to use in practice, every day. It takes a substantial deprogramming to realize that life is all grey, that all reality lies on a continuum. This is why quantitative and scale-based thinking is so important. But most don’t realize that quantitative thinking isn’t really about math; it’s about the idea that The dose makes the poison.
Excerpted from The Value of Grey Thinking at Farnmam Street Blog.
How to Make a Sticker Pack for iOS 10 Messages
TL;DR - No programming needed.

Screenshot of some stickers from the Whisper app Jamin Guy and I used to make for App.net. It’d be fun to be able to use these again.
- Make your sticker images.
- Open Xcode, choose the Sticker Pack template project.
- Drag and drop your images into the default Sticker Pack asset folder.
- Name your images and give them accessibility descriptions.
- Choose whether you want the layout to use a small, medium, or large grid presentation.1
- Done.2
-
This doesn’t seem to affect the actual size the stickers appear to be in the chat area, nor in the grid, but only whether the grid should be spaced for small, medium, or large stickers (4,3,2 across on my iPhone 6s Plus e.g.). This might change in future betas. ↩
-
Okay, you’ll also need to make some new app icons. There’s about a dozen new app icon sizes needed for Messages apps. But that’s just more design work, not programming. ↩
Apple TV Focus Animation Coordinator Bug
If you know how to fix this, please ping me on Twitter.
Since tvOS 9.2, the addCoordinatedAnimations(-:completion:) method of UIFocusAnimationCoordinator has exhibited a strange behavior. Assume you have a collection view whose cells use either affine or 3D scale transforms to scale-up their contents when focused:
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
coordinator.addCoordinatedAnimations({
if self.focused {
self.focusEffectsContainer.transform = CGAffineTransformMakeScale(1.158, 1.158)
} else {
self.focusEffectsContainer.transform = CGAffineTransformIdentity
}
}, completion: nil)
}
If you scroll through the collection view very quickly, cells that acquire and then immediately lose focus before being scrolled into the visible bounds will appear to be scaled-down for a few moments before returning to their identity transform states.
Check out a video of the bug here. You can also download the sample project here
My best guess is that UIFocusAnimationCoordinator’s addCoordinatedAnimations method is using some unclamped animation parameters, which causes the return to an identity transform to over-downscale (like a bouncy animation). This, in conjunction with the (new since 9.2) delay applied to coordinated animations for offscreen views, might be causing the shrunken appearance of the cells awaiting the rest of their unfocusing animations.
I can “resolve” the issue by making nested UIView animation block calls from inside the addCoordinatedAnimations animation block argument, passing animation options that override the inherited curve and duration. But this results in sloppy looking animations all the time, even though it resolves the fast-scrolling transform edge case. I’d prefer to find a workaround that continues to use addCoordinatedAnimations the way it was intended.
Rethinking Apple Music

When I launch an app like Apple Music, I’ve got just a handful of simple questions in mind:
- What have I already been listening to lately?
- What have my friends and heroes been listening to lately?
- What’s everybody else been listening to lately?
- What’s brand new?
- What’s something out of the blue you think I might like?
Apple Music only tries to answer the last of these questions (and it answers it poorly). The other four questions aren’t answered at all.
It’s often a mistake to think that one’s anecdotal experience is representative of people in general, but in this case I believe my music habits aren’t far off from most people’s. Music appreciation is a learned skill. We learn how to enjoy music by imitating our friends and heroes. Whether it’s thumbing through the sun visor CD case of that cool friend from high school, or flipping through your dad’s box of old vinyl, we try on the tastes of other people to see what fits. It’s how our taste grows, embraces new favorites.
The social nature of taste, and of musical taste in particular, is so fundamental that it should be the organizing principle of Apple Music. Here’s how I think they should do it:
- Five New Tabs - Reorganize the top level of the app into five tabs that answer the fundamental questions: Keep Listening, Friends, Everyone, New Releases, and For You.
- Bye, Bye, iPod - Break out all the legacy iPod features into another app.
- Consistent Visual Grammar - Create a consistent visual grammar that allows albums, playlists, and radio stations to exist as siblings on any screen.
- Let Me Choose My Heroes - Make it easy for me to browse the music habits of my heroes, whether they’re celebrities or the cool kids down the street.
I. Five New Tabs
Reorganizing the app into the following tabs will make it map closely to the common modes in which we look for music.
Keep Listening - This tab would show me a dynamic feed of the albums, playlists, and radio stations that I’ve been listening to a lot lately. It’d be sorted intelligently, taking into account things like most recent play dates, play counts, favorites, etc. In the days of CDs, this would be like the discs you had scattered around on your passenger seat or in your book bag. Since it’s software, it should be solving this problem for me without me having to manage anything. With this tab, I could just launch the app and drop the needle on something I probably want to hear again.
Friends - This tab would be similar to the Keep Listening tab, but drawn from the music habits of people I follow, whether friends or celebrities. It even could provide a means to filter down to just the Keep Listening feed of a given user, so I can try out the music that my heroes are listening to. The Internet has the power to make this scale in a way that that physical media never could. Use it.
Everybody - This would be similar to the Friends tab, but instead of drawing from users I follow it would be drawn from all users of the service in aggregate (or at least users in my country). Like the Keep Listening and Friends tabs, it too would contain albums, playlists, and radio stations on equal footing.
New Releases - This should be fairly self explanatory. I’d be alright if this was a Featured tab instead of New Releases, since (for all I know) deals with publishers may require providing top-billing for mainstream artists. Either way, this tab should be where I go to find brand new music.
For You - This tab would be distantly similar to the existing tab of the same name. In addition to albums and playlists, it could also contain radio stations. The Apple-curated playlists and album suggestions need to be thrown out. The tab is supposedly “for me,” so it should be highly sensitive to my particular tastes. Pandora has proved that this is possible. I could care less about what Apple’s curators think I should listen to. If I’m in the mood for borrowing someone else’s taste, I’d rather use the Friends tab. If I want to hear more of my own taste, then I should be able to get that from the For You tab.
Search
While not a tab per-se, all five tabs need to have a persistent, easily-accessible search button. Searching is the one activity (besides playback controls) that needs to be instantly available regardless of the current context.
II. Bye, Bye, iPod
All the vestigial traits from the iPod need to be lanced and sewn together in some other app, buried on a second home screen. Perhaps it could be served from the App Store only if you really need it, like iBooks used to be. The days of owning music are numbered. Even a once-fundamental concept like a collection is no longer relevant in a world where (theoretically) all music is available to all users at the touch of a button. Removing legacy iPod features would eliminate most of the egregious forms of complexity from Apple Music, such as trying to figure out why an album isn’t showing up in the search results.
III. Consistent Visual Grammar
Since the five tabs described above are organized around answering the fundamental questions, this presupposes that each tab is capable of presenting albums, playlists, stations, or some combination of the three. In order to do this without creating confusion, a system should be developed that makes it easy to tell at a glance whether an item in a list is an album or a playlist or a station. Whether it’s by changes in shape or texture, or by filters that hone the the visible results, or some other form of grouping, the precise grammar doesn’t matter so much as the need for consistency. Once I learn how to distinguish the three kinds of items, I should be able to apply that knowledge no matter what screen I’m using. In the current Apple Music app, the presentation of these items varies dramatically depending on which screen you’re on. This inconsistency makes the app difficult to understand and distracts from the browsing experience.
IV. Let Me Choose My Heroes
No algorithm will ever generate as beloved a surprise as snooping through the music habits of one of my heroes. Back when Rdio was alive, whether it was a “celebrity” like the members of Y La Bamba, or a cool Internet friend like Neven Mrgan, my most satisfying surprise musical finds came from browsing the tastes of people I admire. Algorithms have their place (when I’m in the mood for something familiar), but they shouldn’t be used exclusively. Nor should Apple’s hubris be allowed to go on unchecked, filling my Apple Music app with Carly Simon playlists and Jumpman Jumpan Jumpan Jumpan remixes. I want to listen to what my heroes are listening to, and they’re not listening to what Cupertino listens to.