How to check if Safari restricted in Settings?

527 Views Asked by At

When Safari is restricted, [[UIApplication sharedApplication] canOpenURL:url]] return true but when I call [[UIApplication sharedApplication] openURL:url]] nothing happened.

I want to check if Safari restricted in Settings - General - Restrictions.

1

There are 1 best solutions below

0
On

This isn't possible in good way but there always a hackie way to achieve anything. What you need to do is, when you call for safari also set for a global timer before it, schedule it for few seconds (may be 5 seconds), if safari will get open, your app will call - (void)applicationDidEnterBackground:(UIApplication *)application, then you should invalidate the global timer, in other case a timer will fire on scheduled time and you'll get to know that safari couldn't open. Then you can invalidate the timer and show user with appropriate message.

P.S. This what comes to mind when I read the question, I am not sure about other possibilities or ways. There can be some more elegant way.