DEV Community

Cover image for Modular Sign in with Apple in iOS
Abdo
Abdo

Posted on

Modular Sign in with Apple in iOS

This was published fitst @Medium

Over the years, authentication has been a creep for most of the mobile apps. At first, it was required for users to signup to start using any app. Then Apple and UX developers wondered Why users are required to signup for a thing they have not seen or used.

Thus, you should let them taste the application. Then, if they like it enough and would like to access more features, they are required to sign up. This, in turn, leads to having many paths to get your user to the signup process and many entry points.

On the other hand, signing up is a process users always hate because it is a time-consuming process. That's why developers invented a single sign-in button, starting with Facebook, moving on to Google, and Apple, which lately, decided to have its button.

So, How to deal with that in your codebase?

Will you just add it to the login controller, easy? Ok, what if you've multiple login entry points to your app? you'll copy the code? it's just a few SDK imports and login lines, right?
But that doesn't scale well, at all.


Every iOS app is now required to include the new sign in with Apple. Be it a new app, or a current one in the AppStore. For the current apps, Apple extended the deadline to June 30, 2020.


The key idea here is that using this pattern drives me to the fact of how adhering to design patterns impacted my code, making it very robust, composable, and easy to test.

What's the "Strategy" design pattern?

Strategy Design Pattern: is a type of behavioral design pattern that encapsulates a "family" of algorithms and selects one from the pool for use during runtime. The algorithms are interchangeable, meaning that they are substitutable for each other. The key idea is to create objects which represent various strategies(source)


What're we trying to achieve?

An authentication module that can easily be extended with new services, tested, debugged, monitored, and easily reused.
How can that be assembled in swift?
If you liked it so far, please continue reading it on medium.

Top comments (0)