Hello, Nina!

Emannuel Carvalho
Cocoa Academy
Published in
9 min readJun 17, 2020
Nina is finally available in the App Store 🎉

A few months ago I decided to start a project throughout 2020 where I would build an open source app and publish stories about its creation along the way.

The app is supposed to help people prevent from developing Alzheimer's disease. I had the idea after watching this TED talk by the amazing neuroscientist and bestselling author Lisa Genova. Roughly speaking, there are two main areas you can focus in order to help your brain in the battle against Alzheimer's. First, you can avoid amyloid-β concentrations in your brain, by eating a healthy diet, sleeping well and exercising; second, you can create a cognitive reserve, by engaging in cognitive stimulating activities, that will make it harder for the disease to have a noticeable impact on your brain.

In previous posts, I outlined the process I went through in order to decide what the first version of the app should look like. In this post I want to take a look at the first features, introduce you to the code and show some of the tools I’ve been using so far, and outline what I'm planning for the next weeks.

For the features, I will mention:

  • The very first version that I uploaded to TestFlight
  • An updated version with a different UI
  • The 1.0 version that I sent to the App Store

As for the code, I will talk about:

  • Accessing HealthKit
  • Using CoreData for storage
  • Push Notifications with CloudKit
  • Dynamic screens with Bifrost

Maybe some of those subjects will deserve a post for themselves in the future, but for now, I will describe each of them briefly and reference the public repository for more information.

The features

As I said in a previous post, the app will mainly (1) allow the user to input information about their habits and (2) allow them to look how those habits are helping (or not) their brain health.

Version 0.1

The very first version I sent to the beta testers was just another version of the form. I've used some UI code from another app I was developing and I could quickly create some screens where users could say how their sleep was, how they were eating and whether or not they were studying some foreign language.

First version sent to TestFlight

I've uploaded an update soon after the first TestFlight version adding support for HealthKit, so users that used an Apple Watch wouldn't have to answer to the exercise question. Nina would get it automatically.

With that first version I was able to get a lot of insight and adapt what I was thinking for what would be the first version in the App Store, but it was far from being "valuable". It didn't show the user any feedback on how they were doing with their brain health. So it was time to draw some trees.

Version 0.2

Tree visualisation (that's a bad one by the way)

The trees helped people engage more. It made them compare their trees with the others and question more specifically how to improve each aspect (branches and soil). That was very positive and together with the Notifications, the app had the essence of what the MVP should look like.

There were still two modifications I had to make before sending it to the App Store. The first one was make the UI somewhat happier. Adding images and making the relationship between the different activities and the consequences for the user's brain health clearer.

The second was adding another tab with information about the app and about brain health in general. And I decided to make that screen dynamic, so that I could present different information without the need to update the app. At first, there would be a screen with general information on brain health and how it is affected by our habits, with links to other two screens specifically about avoiding amyloid-β concentration and creating a cognitive reserve.

Version 1.0 🚀

The first version on the App Store

Obviously there's still a lot to do in order to improve the app. Firstly, the current experience deserves a closer look with a special attention to UX and UI. The whole experience should feel more cohesive and there is no Visual Identity right now. I shall count on Rafael Feroli to help me with that!

Furthermore, people seem to get more motivated and inspired when they are able to share what they are learning and also see what other people are learning/doing. So I thought of a number of "get inspired" features: sharing what you're reading and looking for books by similar authors, writing and checking on other people's comments about books; sharing the skills you're learning, adding pictures, recipes or projects; track your workout progress.

Besides the experience of sharing what you're doing or learning, another great motivation for us is some healthy competition, so I'm planning on allowing users to challenge each other for competitions; win badges; and share their progress on social media.

There are many other possibilities and, with time, it will be clearer to which direction to go first. But for now, I will start with the "get inspired" features, which, by the way, will allow me to use and discuss some really nice technologies available in iOS.

And since I've mentioned technologies, let's switch gears and talk a little about what I've used so far in the app.

Tools and technologies ⚙️

I have a lot to talk about in terms of code, libraries and frameworks I'm using. I'll try to be brief though, mentioning basically how I'm using HealthKit, CoreData, CloudKit and Bifrost. For the former three, I don't think I need to write a post about them, since there's plenty of good material around. I will write a post on Bifrost, explaining its motivation and how to use it.

If you wanna take a closer look, the code is available here.

HealthKit

Nina uses HealthKit to measure the user's daily exercises. I created a class HealthManager that will handle everything related to Health. It's the only place where HealthKit is imported.

The class basically does two things: it checks whether HealthKit is available and retrieves the user exercise time.

In the future, I may add some features that will generate input to HealthKit, but for now, that's all the HealthManager does.

Core Data

I decided to use Core Data for persistence. There are other options around, but there are always good reasons to use Core Data: firstly, it's very unlikely to be discontinued. Apple has been using and encouraging the use of Core Data for years and it's getting simpler to use every year.

Secondly, I have experienced some tension in the days following the WWDC and Xcode or Swift updates where the libraries I was using suffered from post-update problems. Obviously, that doesn't mean you should never use any external library. However, the decision for using a library or framework should take into consideration the advantages and disadvantages at each case. That said, in this case, Core Data not only did the job perfectly but also was the fastest route.

The model is very simple and you can take a closer look at it in the Nina.xcdatamodel file inside the AppConfiguration directory.

Notifications with CloudKit

Push notifications are one of the reasons we tend to include external (some times very heavy) libraries into our projects. For Nina, once again, I decided to take a simpler approach by using CloudKit.

The idea is very simple. All you have to do is add it to the app Capabilities, create the model scheme at the web dashboard, and add some code to handle the updates in the created model. That code is still at the AppDelegate but I promise to take it to its proper place soon.

Dynamic screens with Bifrost

Like I said, I wanted to have an "Information" tab describing what the app does and how it works. Also, if possible, I'd like to add new information to it, change images, etc. without the need to update the app. So I got an old library I created in a project I worked years ago and made some adjustments. Now it's the Bifrost. It creates views from json data.

So I have an aws lambda that returns a json with the view specification and Bifrost creates a UIView object from that. Also, it can handle simple actions like showing or presenting another dynamic screen. The whole code to handle it is in the DynamicViewController class, inside the InformationFlow directory. And if you wanna take a look at how Bifrost works, you can check this repo.

Disclaimer

Many a time have I desired to have infinite time to improve the app, both from the product perspective as well as the code. But, alas, life is too short and I have named this whole process "The MMXX app project" so it didn't feel right to pass the threshold of June before sending it to the App Store and making the repo public.

There it is.

The app is published! You can download it, check out the code, send me suggestions and propose features and improvements. I'm also trying to learn something about Product Management along the way, so I'll also try to use this board to manage what I'm building.

Coming next

If you're still reading up until here, thank you! That's really impressive. So, I'll mention some of the features I'm planning to add in the weeks to come.

"Get inspired"

The next thing I'm working on is allowing users to share what they are reading, learning, or doing, in order to make them more motivated. People will be able to input or search for information like books, authors, DIY projects, languages being learned, etc.

In the food section, users will be able to upload pictures, with descriptions and recipes so other people can get inspired too.

For exercises, I'll add a few ways for users to track their progress. Maybe they wanna lose weight or get stronger, they will be able to add a picture periodically and then see their progress in a gif or video.

Healthy competition

One thing that I really like about the Activities app is being able to compete with my brothers and friends. I'm planning to add a similar possibility for the users. There's still some refinement to find out exactly what to build, but the general idea is making it possible for the user to challenge a friend, have them track each other progress and by the end of a week, decide who was the winner.

Personalized Information Tab

Like I said before, I'm using an aws lambda to send the json with the views for the Information tab. Right now, it is parameterized by the user language and whether the user is on dark mode or not.

What I'm working on is presenting information according to how the user's habits are. So, for example, if the user is working out, eating well and sleeping well but he or she is not paying much attention to the cognitive reserve part of the equation, the information tab will show how important that is, and so on.

Maybe a few months from now…

Something that may be nice for the users is allowing them to perform the habits that improve their brain health without needing to leave the app. So some crazy features that sometimes cross my mind for the not-so-near future are:

  • Allowing users to read in the app
  • Adding heart rate and HRV measurement for users who don't have an Apple Watch
  • Allowing users to perform some language exercises in the app
  • Adding some simple exercise routines in the app
  • Reminding them to go to sleep on a regular time

Hello, Nina!

So, now that you and Nina are formally introduced, I can't wait for you to download it, use it, provide some feedback and constructive criticism.

Once again, thank you for reading thus far! 🙃

--

--