How to programmatically turn on/off WiFi in iOS? [Swift] - ios

NOTE: I am aware that such a thing violates user's privacy and would be rejected by Apple. However, this specific component is purely for automated testing of buffering behavior when the user's connection is poor/nonexistent. It will NOT be publicly released.
With that said, does anyone know of a way to programmatically turn on/off WiFi in iOS?
I have not been able to find anything up-to-date. Pretty much every answer has to do with this being a violation of privacy and cautioning that they shouldn't do it. Doesn't apply in my case.
Closest I could find was using something like DeviceFarm to simulate it https://docs.aws.amazon.com/devicefarm/latest/developerguide/how-to-simulate-network-connections-and-conditions.html
However, in my case I want these tests to run entirely within the app (private test build). Setting up DeviceFarm for this purpose alone isn't worth it imo.

There is no provision provided by apple to change automate changing its settings because of apple's privacy rule. So you can't achieve by any way.

You can’t. Apple does not allow 3rd party apps to change global system settings like that.
There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
You can’t do that using the iOS application. Apple not allowing it.
Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.

Related

disable internet on other ios apps

I'd like to create a very simple app to block internet access for certain app's between 7PM and 7AM on my iPhone.
However the mobile phone & imessage should stay usable, so it's no airplane modus.
This is to have some "no notification time" and don't see for example new e-mails coming in.
Would this be possible to archieve? Can an app control this behaviour for other app's?
Thanks a lot in advance for your answers!
Best regards,
Koen
No, you cannot do that. Apple "sandboxes" apps so that they have no ability to change the behavior of other apps.
If you did find a way to do that, Apple would reject your app, and probably quickly update the OS to prevent whatever method you used to do it.
EDIT:
You might be able to find a way to do this for jailbroken devices, but obviously those can't be released to the App store.
First thing, Such Apps are not allowed to be published on App Store.
I have worked with private-apis, and i know that this is not possible with only private apis. This may be possible once after you jailbreak your phone + using private libs, and may be you can create tweaks for jailbreak to achieve this functionality.

Is it possible to 'disable' other apps with an app of my own?

I was wondering if its possible to write an ios app that 'disables' other apps from opening?
For example, when I press the disable button on my app, I cannot open whatsapp for the next 15 minutes.
If that's not possible, could a workaround such as blocking all HTTP requests to a certain URL be possible? or even blocking (or turning off) notifications from certain apps?
I've also been wondering whether or not a security module might disallow such code..
Any help would be much appreciated!
None of the suggestion you made in your question will work on a AppStore app. Since the app is sandboxed it can not interact on the level you want with the system.
Your only possibility is to write an app for jailbroken devices.
There might be private API present as per your need but one thing is clear if you target for Apple AppStore ,it will be rejected due to its policy as aslo said by other person. Moreover ,If you still wana develop it you should go for it and there is Cydia which is a appstore for jail broken phone so you could upload your app and try to sell it off. Hope this info is useful for you.

Launching an iOS app on device reboot

I want to write an iOS sample application which can launch itself whenever device is rebooted. Please share your thoughts and any pointers will be really helpful.
Setting VOIP in background modes seems to be one option.
I am NOT looking for a Jail break solution.
There is a way if you have access to MDM tools or the Apple Configurator, and are able to control the device and its' profile. For example, if you are the curator at a museum or you or a teacher and hand out iPads to students, you'll most certainly have this level of control; and since you're writing a sample application, I suppose this level of control is possible as well.
There is a feature known as Single App Mode (see page 17) that locks a device into a single app. According to the documentation, if the device is powered down, the specified app will launch at boot. (I don't have the setup to confirm this.)
Note that Single App Mode is not the same as guided access mode, though people do tend to get them confused.
So should you have access to the right tools your original intent may be possible.
There is really not much you can do to achieve such functionality. The most you can do is to provide background fetching to prepare your app for when user launches it explicitly.
I have never seen a single app that could launch itself for no reason.
Hope this can be useful.
Can't be done unless the device is jailbroken, and I can't help you with that.
To my knowledge, this is not possible. Your app does not have access to this level of system information.
What you could do is periodically send push-notifications with a payload that temporary allows you to access app functionality.

Custom iOS lock app

I'm looking to write a custom lock app to replace the default PIN lock on iOS.
As there are no apps like this available on the App Store currently, its clear that either Apple rejects these types of apps or its just not possible with the currently available APIs.
The app is just for personal use, but I'd just like to know if it's possible before starting. Anyone know which is the case?
Thanks
You can't replace the standard lock screen or PIN entry keyboard EXCEPT on jailbroken devices. First, there's no way to do it with the official SDK. Secondly even if there was Apple would not allow you to modify any of the system applications. If you're serious about doing it though for "personal use" and are OK with voiding your warranty (and/or possibly bricking your device) you could look into jailbreaking and the tools available. A hint in the right direction would be to learn as much as you can about SpringBoard and mobile substrate. Hope that helps.
It's not possible with the current APIs. As soon as someone pushes the home button your app will be sent to the background or terminated depending on how it is configured.

How to jump to system settings on iOS?

If my app detects that the network is disabled, I want to jump to the system network settings. How can I do this in iOS?
There is no way to do this with the current version of the API, and Apple specifically disallows this in their HIG. Presumably this means that if you find a way, your app will be rejected.
There are no documented public APIs allowing you to do this. You can however use Apple's private frameworks, but you won't get an app accepted on the app store this way. It can, however, be used for Ad Hoc distribution and even Cydia for jailbroken apps.
Here's a quick way to get started with the private frameworks.

Resources