set device cellular data on programmatically - ios

I have requirement like when user sign up first time , I need to set cellular data on for my app in device setting.
Is there any way to set cellular data on programmatically for my app?
If no then can anyone give me reason or proof for same? And if yes how we can do that?
I have checked this link: Is there a cellular data usage API in iOS 7? and also checked iOS Detect 3G or WiFi . But can't find solution.

You can't do that, no. If the device is Jailbroken then sure, you can access private APIs and I imagine there is a way to do it. However, if you want to get on the app store, the best hope is to ask the user to enable cellular data.
That's all you can do.

Related

Connecting to Bluetooth device via NFC Swift/iOS

I am working on an App to attempt to automatically connect to a bluetooth device after tapping an NFC button. My original thought of implementing it was to grab the device UUID from NFC, and then attempt to connect in the background. However, if there are any encrypted characteristics this could cause issues as a pairing request would pop up, and I want to avoid that and make the connection as seamless as possible. Is this even possible on iOS, and is there any documentation on this? I have found almost no resources to help, but it seems as there are speakers/headphones out there that have implemented this.
Any idea on where to begin looking would be greatly appreciated. Thanks for your time.

Redirecting Data flow to either wifi or Cellular in ios

I want ot redirect my iPhone data to either wifi or Cellular. Based on some criteria. Is it possible to redirect whole of the iPhone data to a particular interface like to either wifi or cellular. ?
I heard that this can be done using VPN but no idea how it can be done.
Any help on this?
By default, iOS help you with redirection when you have weak/good WiFi and switch on in Setting - WLAN Assist
MultiPath is a technology switching automatically by OS
Just read this Apple Doc for more help.
You can't manipulate it easily with high level API.
After all, changing device data flow is kind of low level thing. Just like NetworkExtension is Apple provided. As far as I know, Apple does not mention it in public.

how to disable wifi assist without user interaction

I have couple of URLs that has to be called(programatically) through wifi not with mobile data.
As WIFI ASSIST is on , whenever the wifi is weak ,packets get transferred through Mobile data.
I would like to stop this from happening.
As far as I have researched, there is no API to toggle wifi assist switch on and off programatically
I can find if the user has mobile data and wifi on with the help of Reachability Class I believe and I can alert the user to keep wifi assist off but this is a very bad user experience.
so I decided to look if its possible to be done with the help of iOS mobile configuration file.
But I couldn't find any keys related with wifi-assist in Apple configuration profile reference.
so I am wondering , is it possible to force wifi to be used for certain URLs.
I remember this is possible with VPN ON DEMAND we can have certain domains to be accessed via VPN.
I am wondering if same is possible for wifi as well through configuration profile
Any suggestions are welcome.
As others have mentioned, there is no way to do manipulate this setting programmatically in iOS. This is not really what you are asking, as you seem to already know the answer to this is "No".
You are asking about the configuration profile, so I am assuming these are managed devices. Unfortunately, there is no configuration profile payload I am aware of that forces the managed devices to disable Wi-Fi Assist.
Your intent, however, is a bit different than what is being asked, I believe. I think you basically have an app that communicates with a resource that is only accessible via the Wi-Fi network (likely a corporate Wi-Fi network). If the app tries to connect to the resource while on cellular, it will not be able to connect. In some cases, when the Wi-Fi signal is weak, the device tries to be helpful and switches to cellular, causing issues with the app. If we could figure out a way to force iOS to not take advantage of Wi-Fi Assist when your app is running, you would be in good shape.
If you can install this app as a managed app, there is a way to identify that the app should only be allowed to run on a Wi-Fi connection. Setting the network usage rules AllowCellularData to false should do this (see this for more details). The thing I am not sure of with this solution, is whether this simply causes the connections to fail when Wi-Fi Assist is on and active, or if it makes iOS prefer to not use Wi-Fi assist when the app is running because it cannot connect over cellular. So I think you can tell an app to only connect over WiFi, but it doesn't really give you a better solution to your user experience problem. The only think it really buys you is that your app connection won't ever try to connect when connected to cellular. There is a chance, however, if you change this value to false for your app bundle ID, it will prevent Wi-Fi Assist from enabling when your app is running. I don't have access to MDM to try it out, but you could test and see.
Ultimately, given that this is probably a corporate device situation, I think you are going to have to address this through user training. The good news is that this is a one-time step. Sure, users may have slight degradation of network performance when Wi-Fi signal is weak but cell signal is strong. This does not matter as much if these are corporate devices where the corporate apps will mostly work only on the company's Wi-Fi network.
Another solution is what you mentioned, basically using on-demand VPN to provide a connection to the internal resources. This is additional infrastructure work, and you already mentioned it, so I'm not sure if it is even an option.
Obviously, the other solution would be to expose the network resources through your firewall, which could allow you to access it over cellular. I'm suspecting this is not possible due to security constraints.
Unfortunately, there are not a lot of good options in this space. However, have hope that there is some way to do it, as Sonos appears to have done something to
allow their app to avoid switching to WiFi Assist while streaming to a local network resource: https://sonos.custhelp.com/app/answers/detail/a_id/4257/~/wi-fi-assist-and-sonos
I wonder if you could have your app open a streaming audio connection to a fixed local network resource, which would cause it to use Wi-Fi. It's a pretty crazy hack, but with a low enough bitrate audio file streaming, it might do what you need while not eating up too much of the network throughput.
Per Apple's notes on Wi-Fi Assist:
Wi-Fi Assist won't automatically switch to cellular if you're data
roaming.
Wi-Fi Assist only works when you have apps running in the
foreground and doesn't activate with background downloading of
content.
Wi-Fi Assist doesn’t activate with some third-party apps
that stream audio or video, or download attachments, like an email
app, as they might use large amounts of data.
Of course the other possible solution that you could consider is improving your Wi-Fi coverage to that the signal doesn't get bad enough for Wi-Fi Assist to be needed. I know this may not be feasible, but wanted to put it out there.
Good luck with this!
There is no public API that allows you to enable/disable "Wi-Fi Assist", and even if you find a way to do it your app will be rejected.
No you can not enable or disable WiFi by programmatically and there is no API for this.

How to ask for authentication before connect to devices using bluetooth?

I want to make demo application, which contains following features.
search and show device list in my device Bluetooth range.
connect(pair) selected devices.
then share string data.
For doing that I am using core Bluetooth framework(Central and peripheral classes). using that I am able to search devices, connect devices and transfer string data also.
but I am not able to authenticate devices before pairing(when I call connect method it is directly shown me connected status). how is it handled in ios?
also please suggest me I am on the right path or I need to use another library to implement this functionality.
For anyone else beating their head against a wall, I have the solution to this issue. It's as simple as setting the AUTHENTICATION required flag for a characteristic on your BLE device. Once that flag is set, you need to attempt a READ from that service / characteristic using the iOS device. Once the read is requested, the BLE device will send back a failure message which then prompts iOS to display the PAIRING / BONDING popup. After that, you're golden.
Here is an example of a Cypress BLE device permission group. The settings are similar for most BLE embedded devices out there.
yes it is possible to ask pairing request from BLE device to ios.
I followed below steps to make ios app to ask for pairing.
edited my ble app to return error code 'RBLE_ATT_ERR_INSUFF_AUTHEN' using gatt write response function.
attempted a write from ios app then i got a prompt to enter pairing key.
used the randomly generated pairing key by BLE device to pair.
Paulw11's comment also helped me to solve that problem,
Regards
Bharath GK

Does iOS give permission to turn on or turn off cellular data within an app?

For example, is it possible to make a widget so that I can turn off cellular data in the Today Widgets?
Without jailbreaking, does iOS give the permission to turn on cellular data?
No, not at a device level. However you can configure your application to not use cellular data.
There is no programmatic interface to disable cellular data.
What do you actually try to achieve: Do you want to turn off the use of cellular data for the whole phone, or do you just access a URL without possibly making it costly for the user because of cellular data?
For the latter, that's an option that you can set before each individual download.

Resources