2 minutes

Permissions Service: An Easy Way to Handle Permissions in iOS

A developer's work is about creating cool products which can provide a good experience for the user. Is that an easy task? Of course, not!

Creation of products mainly consists of business logic and other minor stuff. This stuff implementation can be a trivial task that means we need to do it in many projects. It is not so easy like it appears. There are many cases which can be missed.

One of such situations is when our application needs user data. That means we need to ask user permission and to handle different types of his reaction. How does it work? We have a permission with an unknown state firstly. Then it can be changed depending on user's decision and we need to handle it.

In general developers prefer to implement only good case. But we are in a real world and here exist different bad scenarios:

  • What if our user doesn't allow us to use personal data?
  • What about the "restricted" state?
  • What if the user changes his decision in the Settings of our app?

Therefore, we need to check and handle all these cases. Maybe it is a trivial task, but many developers have problems with this aspect in every project. It is likely that you can accidentally forget about all states or copy-and-paste something the wrong way.

For such special cases, we have created a swift library called "PermissionsService". This library is an easy way to handle all permission cases without having to do it on your own. No more need to deal with error handling for restricted and denied cases, to create and present to the user specific alerts. Additionally, it provides us with the easiest way to see in which state our permission is and to request it. It is already published on GitHub and CocoaPods, which makes it even easier to use. And! The most interesting part is that this is an open source library, so feel free to improve it! Pull requests are welcome.

Of course, it is not a silver bullet, but it can be a good tool for your project. Use it! Make your project easier!


Article Contents: