MoonAge

Using Swift and Mathematical Formulas to Calculate a Person’s Age... Their Moon Age

Client

Teddy Cannon, CEO of Crux Entertainment, Inc

Location

USA

The Background Story

An iOS application that calculates a person’s age based on the moon phase calendar – not the traditional solar calendar – isn’t commonplace. But many people, all over the world, are interested in moon parties and other events tied to moon phases. With MoonAge, they can now find out how old they are by tracking their moon age!

To find out your moon age, all you need to do is enter your birthdate and birthplace into the MoonAge application. The app then shows not only your moon age, but also under what kind of moon you were born. MoonAge automatically calculates and updates a person’s age based on new full moon phases.

Teddy Cannon wanted to develop this non-traditional age calculator, and we at RubyGarage developed his small project into a simple iOS application.

Solution

Even the simplest mobile applications require a thoughtful approach. We used several third-party libraries to build an effective MoonAge backend and UI as quickly as possible.

Since MoonAge is the only iOS application of its kind, we didn’t have any relevant experience for building such an age calculator. First, we wrote a mathematical formula that determines a person’s moon age. We used the Lune.js library as a starting point, and implemented all JavaScript calculations in the Swift language.

The main screen has two tabs – Horoscope and MoonAge – and we developed a custom button to let users switch between those tabs. This button was created without the use of additional UI files, and is based on the single CAGradientLayer class. It’s as simple as that!

When building MoonAge, we developed several custom animations as well. For example, when MoonAge users save their personal data in the app, they need to tap on the name of a location field. The placeholder for this field floats to the top and allows the user to enter their data.

We used a custom class to allow MoonAge users to check for existing notifications and their schedule, change the time when notifications are pushed, and turn on and off notifications.

Notable Challenges

Calculating a Person’s Moon Age

We ported mathematical formulas for calculating moon age from the Lune.js library to Swift. Moon parameters were encapsulated into a single MoonPhaseManager class.

Network Requests

To perform network requests, we implemented the Alamofire networking library into MoonAge. We also simplified our work with Alamofire by creating an ApiClient class that allows us to use GET, POST, DELETE, PATCH, and PUT methods with necessary parameters, such as NSData.

Switching Between Tabs

We implemented a custom button, fully rendered in code without UI files, for switching between tabs in the MoonAge application.

Share Button with Pulsator

We used a third-party library called Pulsator to create an animated share button. Pulsator is easy to customize for any iOS application, so we opted for it when building MoonAge.

Local Notifications

We wrote a special LocalNotificationsManager class to support local notifications in MoonAge. We combined all the logic to manage notifications in this single class.

MoonAge

Teddy Cannon

CEO of Crux Entertainment, Inc

As an entrepreneur, I believe that by nature I get the thrill of projects, that I do not know how to implement correctly. Before I stepped into mobile app development, I talked to many people and got many recommendations for companies to work with. And, although many of the recommended companies were very reputable, there was something different and exciting about RubyGarage. After several in-depth Skype meetings, there was no question that they were my app developers. They remained open-minded, continued to question and together we brought a wild idea to life. Throughout the whole process, I felt safe to brainstorm with them about a project. That safety has fostered a great partnership. I highly recommend RubyGarage on so many levels.