My application's users don't like interruptions like incoming phone calls. I want to find out if the device is in Airplane mode, warn the user about possible interruptions and recommend invoking Airplane mode.
The reachability examples tell me if the device has a network connection, but it's possible that WiFi is on while the phone is in Airplane mode.
You should just be able to check the kSCNetworkReachabilityFlagsIsWWAN flag (have a look at the Reachability.m class and change it to your heart's content).
Related
I am studying about coding and I got a question to control airplane mode in iphone programmatically
For android phone, we can use usb connection and adb to send unix command to control airplane mode.
Is there any possibility to control airplane mode by unix command and lighting cable connection?
I was checking
ios: turn on/off airplane mode from code for iPhone / iPad
How to check Airplane mode in background in iPhone?
but i am not clearly sure if it is possible...
No, you just can't do that.
An app has to adopt to the current network state, not control it.
You would need to access the private API and this would mean, you can't upload the app to the App Store because it is not allowed to use the private API in productive mode.
I want to connect a robot, via Bluetooth, with an iPhone (4S or more) via Bluetooth low energy (BLE) 4.0. This robots require to send all the notifications of the iPhone to the device.
For example: If the iPhone gets a new email, I must send the event to the robot, and it will blink an LED. Stop.
I want to know if the iOS Bluetooth APIs of the Bluetooth framework can do this, or better, can share the Internet connection or whatever that can do this work.
I'm asking this, because I have heard that the APIs have some restrictions.
PS: ANY solution that can do this is very accepted (no Wi-Fi connection solution).
Bluetooth LE would be the way you want to go here, because standard Bluetooth requires your device to be MFi-compliant. Standard Wi-Fi could also work, if you're able to require the presence of the supporting network.
As of iOS 6.0, you can set up your iPhone as a Bluetooth LE peripheral, which would allow it to send notifications to your device, if it is configured in a central role. That would be a pretty power-efficient way of updating your device with new data.
However, there's one large hurdle to doing what you want here. iOS applications have no access to system-wide notifications, so you won't be able to listen for incoming emails or other notifications like that. You'll be able to send data to your device via Bluetooth LE, but you're not going to know when emails come in so that you could send that to your device.
With bluetooth 4, you could control a robot, as well as create a "notification" bot. It could be done quite easily. However as mentioned, you can't access system wide notifications in iOS.
However, you could use an external solution to listen for system notifications and then an API to listen a singular encoded notification and have your app listen to that.
One such system is https://ifttt.com (no affiliation)
There are also some great plug and play BLE options for rapid prototyping.
You can do it. A simple solution would be let a phone check your email periodically. Don't rely or try to use external Apple applications to do that, but use services provided by your mail.
In the case of Gmail, try to go to https://mail.google.com/mail/feed/atom. If you are logged in your Gmail, you will see the unread mail in XML format. The way you would login using a URL is: https://username:password#mail.google.com/mail/feed/atom
So what you can do is periodically parse the output and when <fullcount>0</fullcount> value changes call your robot service via BLE which should act as a callback for this specific event.
Situation: My iPhone communicates to an external device through Wi-Fi. The app has also the ability to set up a schedule. This means that on a specific time the device should turn on and do some stuff. Now for this to happen there should be a timer on the external device or the iPhone should send a command to the device on a specific time.
Question: Is it possible to send a command to the external device while the app is in the background? Or does the app have to be in the foreground? Is it possible when the external device is an accesory? Cause I have read that apps are allowed to run in the background when they need to communicate to accessories??
Thanks in advance!
No you can't do this, you are only able to run an app in the background if its stream audio, a VOIP client or track user location. If you are in the accessories program (which means you can make hardware that works with the dock connector, then your app can also run in the background. but only if the accessories that is respons to is connected.
There is no way the schedule any operation to be triggered at a set time.
You can schedule a local notification, but the user wil have to view (open you app by click in the notification) before you app get informed about it.
Do you actually have the devices communicating? If not, you should take a look at Apple's MFI (Made for iPhone) program. Sending data or communicating from your iPhone to an external accessory through bluetooth falls under it. They provide you with certain protocol specifications that allow you to communicate with external accessories. It's difficult to do something like this if you are an individual developer though. Here's the link: https://developer.apple.com/programs/mfi/.
Apple's built-in applications show a pop-up message whenever the user doesn't have cellular or wifi connectivity. It looks something like:
"Cellular data is Turned Off
Turn on cellular data or use Wi-Fi to access data
[Settings] [OK]"
Clicking on the Settings button opens the settings panel.
Is this a system pop-up? How can I use it in my own application?
I'm already using UIRequiresPersistentWiFi but it uses a different type of message which appears when airplane mode is on.
Thanks!
You need to enable Application uses Wi-Fi in info.plist. Then this warning is displayed when cellular data is turned off and you're not connected to wi-fi.
Look at the Reachability example in Apple's Sample code. It will give you all the code you need to determine if you're connected or not to the internet.
I want to check the user whether using whether wifi/3G connect or not, how can I check this behavior? thank you.
Use Apple's "Reachability" sample app. It's become the code most used for determining network connectivity.
http://developer.apple.com/iphone/library/samplecode/Reachability/Introduction/Intro.html
You can check once at launch time for network access, or set yourself up as a notification consumer of network connection change messages.
This is important these days because Apple will test your app in Airplane Mode, and if it requires network connections it can't get, but doesn't handle that nicely, they'll bounce your submission.