August 24, 2017

Engineering Jedi: Maximize Connectivity in iOS 11

We’ve made you aware of things you should prepare for with iOS 11, now we’re looking at something more specific: how poor network connectivity will be handled with the upcoming iOS update. The lay user just needs to know you may use slightly more mobile data than you have before once you update to iOS 11. But for our fellow developers, we’re going deep into this subject below. Put on your engineer hats!

In iOS 11, Apple has made a number of improvements to the URLSession family of APIs. These improvements range from developer quality of life updates, to significant performance gains that will undoubtedly improve user experiences across the platform. In this post, we’ll go over two improvements in particular: Multipath TCP support and reachability monitoring built-in to URLSession.

Multipath TCP

Elegantly handling poor network conditions is a sure sign of a well-built and polished app.  Compared to most other apps on your phone, have you ever noticed how rarely Siri seems to have connectivity issues? The reason for this is Multipath TCP. When Siri makes a network request, the app actually opens up two connections to the server: one over Wi-Fi and one over cellular. These connections work together to deliver data to the app as quickly as possible. As long as your device has a decent connection on one of the two channels, Siri works.

Multipath TCP is a relatively new protocol, designed specifically for mobile devices. It is built on top of TCP, so it benefits from the reliability and congestion controls built into TCP. Additionally, MPTCP allows for seamlessly switching between a wireless and cellular connection. It even supports using both connections simultaneously to increase throughput (more on this later).

In order to take advantage of MPTCP, support is required at both the Client and Server level. Not all server infrastructures currently support MPTCP, but popular vendors like AWS do. With iOS 11, app developers can now support MPTCP at the client level as well.

Modes

In iOS 11, apps can opt into three different MPTCP modes: Handover Mode, Interactive Mode, and Aggregate Mode

  • Handover Mode: Connection will be made over Wi-Fi when possible. If Wi-Fi network conditions are poor, the system will automatically spin up a cellular link and transfer the traffic to it. As Wi-Fi conditions improve, traffic will be transferred back to a Wi-Fi connection and the cellular link will be torn down. Essentially, handover mode attempts to minimize cellular usage while still maintaining acceptable performance. All of this happens in URLSession and is completely transparent to our apps.
Diagram of cell tower and wifi for Handover mode
  • Interactive Mode: The system will immediately spin up both a Wi-Fi and Cellular link. While Wi-Fi is still preferred, the system will be aggressive about transferring to cellular if it finds that Wi-Fi conditions are not ideal. Interactive mode is optimized for performance, at the cost of cellular data usage. Siri uses Interactive mode.
  • Aggregate Mode: Like Interactive mode, the system will immediately spin up two links. However, both links will be used together to increase the overall throughput of the network. In theory, using Aggregate mode over a 10mbps Wi-Fi connection and a 5mbps cellular network could result in a 15mbps connection to your server! While this is very cool, it can cause significant cellular data usage. Because of this, Apple is not allowing Aggregate Mode to run in Production apps. Aggregate mode is, however, available to developers via the Developer Settings screen in the Settings app.

Regardless of which mode is used, the cellular link will be disabled if your app hits the Wi-Fi assist data limit. Be on the lookout for this if you are testing your apps and notice MPTCP no longer switching over to cellular. This is a good indicator that you may need to rethink which calls are opted in to MPTCP.

Opting In

So, how do you opt in? Apple has made this extremely easy. Simply add the “multipath” capability to your app in Xcode, and set the multipathServiceType property on your URLSessionConfiguration to either .handover or .interactive. That’s it!

xcode example of activating handover mode

Reachability

Good reachability handling has always been tricky in iOS, mostly due to the absence of solid high-level support for it. Most apps use third- partyreachability libraries, all of which are built on top of Apple’s SCNetworkReachability low-level API. There are some issues with this approach: the libraries are not particularly reliable, and they are not integrated with URLSession. If a developer needs to hold off on making a network request until network conditions improve, or retry a network request, they have to build that functionality up from scratch themselves. That ends up being cumbersome for developers, results in less than ideal reachability handling, and also takes time away from polishing the user experience. Developers often take the easy route and present a full-screen modal as soon as connectivity is lost, blocking the user out of the app completely.

Apple has improved a number of these pain points in iOS 11. URLSession now has the ability to monitor network conditions and wait to start tasks. You can easily opt in to this behavior by setting waitsForConnectivity to true on your session’s configuration. When opted in to waitsForConnectivity, URLSession will either load the request immediately or load the request as soon as network conditions allow. While waitsForConnectivity is defaulted to false for backwards compatibility, Apple recommends enabling it for almost all requests.

In addition to delaying network requests, URLSession will now notify your app when it experiences poor connectivity. This is accomplished via the urlSession(_:taskIsWaitingForConnectivity:) delegate callback. You can hook into this delegate callback and use it to toggle Connectivity UI.

Do you have burning questions about connectivity with iOS 11? Our developers, responsible for numerous award-winning apps and connected device experiences, have the answers. Tell us what you’re wondering at [email protected]

August 14, 2017

From the Mouths of Interns

The time has come to bid our most recent team of interns adieu. This year, our internships spanned disciplines from engineering to experience design (XD) to project management. Before they rode off into the sunset for even more educational adventures, we asked our interns a few questions about their time in Bottle Rocket’s hallowed halls. Here’s what they had to say.

What was your favorite project/event/etc. during your internship? 

Ben Allgeier, iOS InternRocket Science ended up being my favorite.

Aabid Shivji, Project Management Intern – My favorite event had to be Rocket Science. It was so cool that the company let you loose to just work on something that you cared about and wanted to see come to fruition.

Parag Dakle, Android Intern – Being a part of updating a project for a big-name client.

Jake Rowland, Android Intern – Rocket Science. It was awesome to have dedicated time to work on something new and innovative. I love the idea of having one day a year where you can learn something new or start a project you’ve always wanted to work on.

Kristen Kirk, XD Intern – My favorite project I got the opportunity to work on was for a client who was looking for a new app that didn’t fit the “standard” look of most apps. It made me think in a very fun, abstract, and critical way.

Thomas Wheeler, iOS Intern – Rocket Science. Always.

What was your biggest takeaway from your internship? 

Ben Allgeier, iOS Intern – Make sure you know how to use GitHub and that you are on the right branch.

Aabid Shivji, Project Management Intern – I think my biggest takeaway from my time at Bottle Rocket is that checking yourself and your ability is really important. One of the coolest things about my experience here has been that I’ve been humbled every single day by being an industry outsider in this office.

Parag Dakle, Android Intern – Always keep learning. Become an Engineering Jedi! They are crazy and cool.

Jake Rowland, Android Intern – Libraries are your friend (unless you have to support depreciated libraries). Why try to rewrite code you have access to it for free? 

Kristen Kirk, XD Intern – My biggest takeaway would be learning how to manage my time on projects as well as managing time for myself to regroup and get new inspiration and ideas.

Thomas Wheeler, iOS Intern – Start with the user in mind and find the technology that fits. Not the other way around.

What advice would you give to next year’s interns? 

Ben Allgeier, iOS Intern – Prepare and ask questions at training or any other time you have them. Somebody will be willing to help you.

Aabid Shivji, Project Management Intern – Come in with a growth mindset and a strong desire to learn. In many ways, the thing about this company I’ve loved the most has been that the environment and culture is designed to help you to succeed and get as much knowledge as you want out of it. Interns should come in and really try to take advantage of this, because I’ve learned that the people here are more than willing to talk to you and answer any questions you may have, so it’s only reasonable to ask as many questions as you can before your time at Bottle Rocket is over.

Parag Dakle, Android Intern – Convince the Recruiter, Julian, to make the internship last longer!

Jake Rowland, Android Intern – Know GitHub before you arrive. It really helped me have a head start in my internship already knowing some Git commands and how Git functioned.

Kristen Kirk, XD Intern – My advice for next year’s interns would be to network. Meet as many people as you can and build relationships with them because it will help you when you have no clue what to do. This way, you’ll know people you can bounce ideas off of as well as talk to later down the road as a reference.

Thomas Wheeler, iOS Intern – Work hard. Be nice. Learn every day.

Interested in a Bottle Rocket internship? Ask us what it takes at [email protected].

July 10, 2017

Engineering Jedi: iOS Breakpoint Secret Sauce for Better Debugging

As most iOS developers are aware, breakpoints are an essential tool to debugging apps. In Xcode, setting a breakpoint is as easy as clicking on the line number that you want to pause app execution on. When execution is paused, you can view the state of any variables in scope, issue commands to the debugger, and even step through your code line-by-line to watch the execution flow unfold before your eyes.

gif of setting up a point break in xcode

To make your debugging experience with breakpoints even better, we’ll cover the 5 breakpoints that every iOS developer should enable. If you’re a seasoned iOS developer, you may already know about some of these. If you’re new to iOS development, don’t worry, we’ll start with a quick overview of how to setup and use breakpoints.

The Breakpoint Navigator

Managing breakpoints in Xcode is super simple. Enter the Breakpoint Navigator, which lives in the Navigator Panel on the left side of Xcode. Here, you will see all the breakpoints currently set in your project. Click on the name of the method to jump right to that line of code or click on the blue breakpoint icon to enable/disable the breakpoint. Removing a breakpoint is as easy as dragging it outside of the panel.

screenshot of breakpoint navigator UI

Symbolic Breakpoints

While it’s very useful to set breakpoints on specific lines of code, it can also be helpful to have some breakpoints function globally. Symbolic breakpoints are breakpoints that will trigger on certain conditions, like any time a certain method is called on a class. Adding a symbolic breakpoint is achieved by clicking the "+" icon at the lower left of the Breakpoint Navigator and selecting “Symbolic Breakpoint”.

selecting symbolic breakpoint in breakpoint navigator

The Top 5 Xcode Breakpoints

Here we are, the secret sauce! Use the "+" button at the bottom left of the Breakpoint Navigator to add the following breakpoints:

All Objective-C Exceptions

This breakpoint catches exceptions thrown by Objective-C code. Due to the current transition to Swift, this breakpoint isn’t as useful as it once was, but it can still be handy if your app contains any Objective-C code or uses third-party libraries that are written in Objective-C.

Turn it on:

  1. Add an "Exception Breakpoint"
  2. Change the "Exception" value from "All" to "Objective-C"
  3. Click "Add Action" to add a "Debugger Command" action
  4. Type in "po $arg1" for the command. This will automatically print the relevant error to the console when you encounter an exception
adding in all breakpoint exceptions

-[UIApplication main]

This puts a breakpoint at the entry point to your application’s launch. We’ll be using the "Debugger Command" action again to have our debugger import UIKit, which will make the debugger much more aware of properties and methods on things like UIView. This will make it easier to interact with and print properties on these types of classes when you’re debugging.

Turn it on:

  1. Add a "Symbolic Breakpoint"
  2. Type in "-[UIApplication main]" for the Symbol
  3. Add a "Debugger Command" action
  4. Enter "expr @import UIKit" for the command
  5. Check "Automatically continue after evaluating actions" — this will ensure that your app doesn’t immediately pause execution every time you build and run
adding breakpoint in debugger command

UIViewAlertForUnsatisfiableConstraints

This breakpoint helps you catch undesirable constraint configurations. If you’ve ever seen the “unable to simultaneously satisfy constraints” error message in the console, it will suggest you set a breakpoint here. Usually, these situations don’t cause obvious visual errors, but they should be fixed since we don’t know how they will be handled in future versions of iOS.

setting up UIViewAlertForUnsatisfiableConstraints

Turn it on:

  1. Add a "Symbolic Breakpoint"
  2. Type in "UIViewAlertForUnsatisfiableConstraints" for the Symbol

NOTE: In Xcode 9, there is a new "Constraint Error" breakpoint that can be used instead of manually creating this symbolic breakpoint.

using constraint error breakpoint instead of using UIViewAlertForUnsatisfiableConstraints

-[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:]

This is another breakpoint to help you identify Auto Layout constraint problems. Hitting this breakpoint is typically much less common than hitting the "UIViewAlertForUnsatisfiableConstraints" breakpoint above, but it’s still good to go ahead and make sure you turn this one on.

Turn it on:

  1. Add a "Symbolic Breakpoint"
  2. Enter "-[UIView(UIConstraintBasedLayout) _viewHierarchyUnpreparedForConstraint:]" for the Symbol
breakpoint to identify Auto Layout constraint issues

UICollectionViewFlowLayoutBreakForInvalidSizes

This last breakpoint helps catch layout errors in UICollectionView’s flow layout. This is especially useful if you ever work with self-sizing collection view cells or create your own flow layout subclass.

Turn it on:

  1. Add a "Symbolic Breakpoint"
  2. Enter "UICollectionViewFlowLayoutBreakForInvalidSizes" for the Symbol
catching errors in UICollectionView's flow layout

One More Thing - User Breakpoints

As you can imagine, it can be quite tedious and time consuming to create all five of these breakpoints for every project you work on. This is where the power of promoting your project breakpoints to "User Breakpoints" comes into play. User Breakpoints will automatically be present in any Xcode project you open! To convert a breakpoint to a user breakpoint, right-click on the breakpoint and choose "Move Breakpoint To" -> "User."

When everything is said and done, you should now have five breakpoints listed under "User" in the Breakpoint Navigator. These breakpoints will be set up for any Xcode project you open from here on out. Also, notice that any project-specific breakpoints will be listed above these "User" breakpoints, under your project’s name.

checking the 5 breakpoints in breakpoint navigator

June 20, 2017

Engineering Jedi: Five(ish) Things to Prepare for with iOS 11

Now that WWDC 2017 has concluded, it's time to evaluate any apps you currently have in the App Store, as well as any soon to be released, to ensure that they're ready for the new version of iOS. It's not a very long list, but the changes are important.

  1. Prepare for the new App Store look and feel. Your app will get a new presentation style, and you're encouraged more than ever to use video to demonstrate the app. Also, reviews no longer reset with each submission to the App Store, so it's a good idea to decide on what interval you wish to reset those ratings averages. Related to the new store: you may need to remove any existing mechanisms prompting the user to rate the app. Starting now, only the built-in functionality is allowed for prompting the user. You can still use any techniques you prefer to decide when the stock technology should present the request, but be aware that the user will only receive that prompt at most three times per year, and may never see it due to choices that they've made.
  2. Apple has provided a new set of tools for determining where items should be placed on screen. Hopefully your app is already using AutoLayout, and is prepared for multiple device layouts using size classes. These have been around for a while, and should be considered the bare minimum for supporting modern devices. In addition, there's now a concept of the "safe area" on an iOS device. This is the area of the screen where critical user interactions should take place. This concept is common for development for televisions to account for overscan, but is new for iOS development. This may indicate that in future devices, interactive elements might not work if they're too close to the edge of the screen. Prepare now, and you can ensure that future devices won't hamper your users' experiences.
  3. In iOS 11, users can allow location services either in-app only or at any time. Some apps are designed to work only if they have access to the user's location at all times. These apps need to reconsider their location usage strategy and adapt to this new requirement.
  4. If your app uses a custom typeface, it is now much simpler to support dynamic type with those custom typefaces. This is often the first step in making your app accessible, and now you can easily set up your app to handle this combination of dynamic type and accessibility. If you had done this using some arbitrary custom code before, you can now handle it more completely and safely.
  5. Finally, if your app runs on the iPad, the time has never been more appropriate to adopt multitasking. With the new multitasking features and drag-and-drop support, it's more important than ever to support these techniques, so that your app remains relevant to advanced users of these devices.

Once you've completed these must-do tasks, there are a few other things that can help make your app more modern and relevant. Generally speaking, these are more technical, so you don't necessarily need to keep going from this point.

The first of these optional items would be replacing any icons in your app with vector art. You've been able to use PDF vector art to provide images for quite some time, and there are additional areas where these will be used (such as accessibility hints for toolbars). This should be a straightforward change for ongoing development.

The second optional item would be to simplify any of your custom JSON transformations using the new Swift Codable protocol. This functionality should be backward compatible back to iOS 6, and this can give you a simpler, lighter-weight application.

If you support a user login system on the web as well as your app, you should definitely prepare to share those logins using the new password support. There are very few steps needed to complete these logins, and it can allow the user to use more secure passwords.

You should consider updating any animations in your app that are frame-locked to 60Hz. Having animations locked to a particular refresh rate can cause less-than-ideal appearance on the most recent iPad pro, which has a 120Hz refresh rate. Future devices may have refresh rates other than 60Hz as well, so preparing for that future would be a wise move.

Hopefully you're inspired to get your app ready for the next version of iOS. If you get started now, this is a very light lift for most apps that have been well maintained. Your users are certain to be appreciative of your app if it's kept current with the latest developments.

Want to make sure your app is ready for iOS 11? Reach out and let’s talk about it.

June 19, 2017

Top Takeaways from WWDC 2017 that Weren’t in the Keynote

While there were a lot of big announcements during this year’s WWDC Keynote, there were even more our Rocketeers learned during the sessions following it. Some of these barely made an appearance at the conference, but we think they’re some of the most exciting updates yet. If you are interested in learning more about these topics, you are also welcome to watch our webinar that aired Wednesday, June 14, 2017.  Click here to watch.

Business Chat Could Change Everything

Any business large enough to have a call center or customer support group should take note. Business Chat opens a support line directly in iMessages making it easier than ever help solve everyday customer problems with a tool that’s familiar to everyone. This interaction can begin from a button in an app, a link on your website, a CTA in an order confirmation email, or pretty much anywhere else you’d want to put it. Within the chat, you can share files, images, product images and/or videos, and much more. For example, let’s say a customer wanted to upgrade or change their seat on a flight – the airline could send them a layout of the seats available and can even charge for the upgrade through Apple Pay directly in iMessage. If you wanted to schedule a meeting, the details will be saved directly to the calendar.

Business Chat is available today and already integrates with LivePerson, Salesforce, Nuance, and Genesys.

CoreNFC Now Open to Developers

Near Field Communication (NFC) has been around for several years now, and the odds are good that you’ve used it and didn’t even know. NFC can be used for a wide range of applications, but to date it has primarily been used for mobile payment through apps such as Apple Pay. However, that may change very soon as Apple has officially opened the iPhone’s NFC functionality to developers. In true Apple style, they have taken every precaution to ensure user data remains secure. Each session must be initiated by the user and developers can only read, not write, data from an NFC tag. This means there will never be an accidental scan or possibility of someone pulling information from your phone. Brands will be able to leverage NFC for everything from presenting more information about a painting in a museum to adding items to an account in a hotel – but they will not be able to bill you directly from the interaction.

QR Reader Added to Default Camera App

In the United States, QR code sightings can be uncommon depending on where you live. In eastern markets, they are much more common. QR codes failed to reach widespread adoption in America because some didn’t know what to do with them and others didn’t see the value in downloading an app specifically for reading them. Now that Apple has integrated a QR reader into the default Camera app, that could change. However, western adoption of QR codes relies on content creators and advertisers just as much as, if not more than, users interacting with them. QR codes can be used for a wide range of applications such as sharing a playlist, opening a YouTube video, downloading an app, adding an item to a cart, and much more. The more interesting the experience, the more likely users are to give QR codes a try. To best leverage them, think guerilla marketing mixed with surprise and delight – people should feel as though they found something special rather than an advertisement, and where it takes them should almost be a reward.

CoreML Brings Machine Learning to the iPhone

The ways Google and Apple have approached artificial intelligence (AI) and machine learning (ML) are very different. One of the biggest differences is where the “magic” happens. Google’s approach is in the cloud while Apple’s is on-device. Processing the information on the iPhone itself not only provides a much faster experience but a much more private one. CoreML has three offerings at the moment, including Vision for image analysis, Foundation for language processing, and GameplayKit for NPC (non-player character) behavior, pathfinding, and more. While GameplayKit will mostly be used by game developers, Vision and Foundation can be used for a multitude of applications. For example, Vision can be used to recognize barcodes. You could use Vision to show more information about a product after a consumer scans the barcode or, with some training, teach Siri to recognize the product itself so that they can simply take a picture of the product to learn more.

Siri’s New Extensions

Three new extensions are now available to developers through SiriKit. For apps that allow you to make or check off items on a list, Siri can now be integrated into the app to allow users to take actions around those lists. The other two extensions, Points and Domains, can be leveraged for rewards and loyalty points. Points will allow users to ask Siri questions, such as “do I have enough points to book a flight to LA?” and Domains will allow users to scan visual codes such as loyalty points on a purchase to have them automatically added to your account in the app. With Siri’s new extensions, the customer experience in apps can be improved greatly as Siri makes it easier for consumers to keep track and add reward points to their accounts.

The App Store Gets an Overhaul

There are some big changes coming to the App Store. First off, Apple has completely redesigned the store and added several sections to improve the app discovery experience. There will be three primary sections to the store – Apps, Games, and Today. To make it even easier to decide if you want to download an app, Apple has also added the option for developers to upload up to three videos to showcase gameplay, features, and more in apps. What’s even more exciting is that Apple now allows developers to decide if they want to reset their reviews when uploading a new version of an app. Believe it or not, some developers would allow bugs to go unfixed for weeks if they had high ratings for their app to avoid having the ratings potentially drop. Now hotfixes are much less stressful for brands and developers as they can effectively push out several builds of an app and retain their ratings and reviews.

Check back for more updates as these new features and tools become available. In the meantime, please feel free to contact us with any other questions you may have.

© 2020 Bottle Rocket. All Rights Reserved.