Developing a Christmas snow Easter egg — available app wide in the iOS Takeaway apps

Fady Yecob
Just Eat Takeaway-tech
5 min readDec 30, 2021

Working as an iOS engineer at a big company like Just Eat Takeaway.com, you might think that you always have to work on serious features or improvements. While this may be the case most of the time, it doesn't mean that you can't be creative and think of a fun feature or Easter egg to build. And of course execute on that idea.

This article will highlight a fun Easter egg we built into the Takeaway apps which shows a fun snow effect whenever the user shakes their device.

How it started 🏁 (2019)

The original idea to add some kind snow Easter egg to the Takeaway apps started all the way back in October of 2019. The original idea was to add a snow effect during Christmas inside the stretchy header that we had back then. I made a small demo back then and shared it in a Slack channel, which looked like this:

The original demo, created in 2019

The idea did gain some traction and we were already thinking of adding a remote config so it would only be active within a certain range of dates. And the Android engineers were even thinking of ways to build it into the Android version (using this library). It went to the Product Owner and Designer. But sadly due to other priorities, we didn’t build it into the app that year.

How it continued 🛠 (2020)

The idea was once again brought up in September of 2020. So it once again gained some traction. And this time it went to the designer who actually created a design and custom snow particles. But the app was also going to change that year and the stretchy header would be removed, so the idea changed a bit.

So instead of having the snow effect inside the stretchy header, we would show the snow effect whenever the user would shake their device. Which would resemble a snow globe. We decided we would have a range of dates which decided if the effect would be active. So e.g. it would only show if the user shakes their device between December 1st and January 15th. And we also decided that the snow effect would have a fixed time until it would stop.

We decided to store all these values in a remote config. Since we were already using Optimizely for feature toggles and experiments, the remote config would be stored there. This remote config would make it easy to change the range of dates and the amount of second the effect is active.

So following all these changes and decisions, we decided to actually build it into the iOS app that year. In our team we work with scrum. Since the feature had already gone past the product owner and the designer. We only needed a ticket / user story. Which then needs to be prioritised into one of our sprints. So following this I created a ticket. Our team already knew about the idea since it was shared in a Slack channel. So during a sprint planning meeting the ticket got brought up. And with our product owner and team lead it got planned into the sprint as something on the side for when everything was done.

So now you would think, all is good and the Easter egg launched that year? The answer is: No. Sadly that year we didn't finish building the feature in time and it didn't make the release cut.

It launched 🎉 (2021)

So this year, we had already built everything and all that was left to do was enable the Easter egg. Which we did with the feature toggle we had built the previous year. We decided to test out the waters and enable it in the Netherlands first. Since there were no issues, we enabled it in all other countries. Which are the following countries:

So all in all there's quite a lot of users (several millions of monthly active users) that can discover this little Easter egg if they shake their iOS device. You can see what it looks like in the gif below:

The final version of the Christmas Easter egg

The Tech ⚙️

As mentioned in the previous sections of this article, we used Optimizely for the remote config and feature toggle. At the time of writing this article, Optimizely doesn't support dates, it currently only supports the following variable types:

  • Boolean
  • Double
  • Integer
  • String
  • JSON

So in order to store dates in the configuration we used the JSON variable type, which looks like:

Remote JSON config in Optimizely

The start and end date in this JSON block are quite straight forward. The duration represents the amount of seconds the effect will be shown after the user shakes their device. This data is mirrored in the Swift code like this:

Snow easter egg model

The data is fetched from Optimizely which returns an OptimizelyJSON object. Since we don't want this we just basically convert it to a Dictionary with the toMap() function and use JSONSerialization.data(withJSONObject:) to get a Data struct. This data can then basically be parsed using a JSONDecoder with the iso8601 date decoding strategy.

Creating a snow particle emitter

We basically used 8 different images for our snow flake image. We put these image names in a CaseIterable enum. This can be seen below:

The snow flake images as an enum

A particle emitter in Swift/iOS consists of 2 parts:

We created subclasses of these with a bunch values. Since snow in real life is also quite random, these properties are quite random as well as can be seen in the code sample below:

The CAEmitterLayer and CAEmitterCell

Where do you use the particle emitter?

Since we have our own subclass of UIWindow in our app, that's where we called the particle emitter. This basically has the motionEnded function since it inherits from UIResponder. A lot of other base classes in UIKit inherit from UIResponder, like UIView, UIViewController and UIApplication. We basically override the function in the code sample below to then use the particle emitter:

Overriding the motionEnded in your UIWindow subclass

Conclusion

As you can see by the code, adding a fun Easter egg can be quite easy to do. Though sometimes it can take quite a long time for the Easter egg itself to make it to the app. In this case the first idea of the Easter egg started started in 2019 and went live 2 years later in 2021. Since an Easter egg is not something that will actually improve anything for the customer, it will often take a back seat compared to other things.

If you're reading this article around December or January, try shaking your iOS device with the Takeaway app. You never know what you might find ❄️

--

--

Fady Yecob
Just Eat Takeaway-tech

iOS Software Development Engineer @ Just Eat Takeaway