Is it possible to detect LTE connection using iOS SDK? - ios

I'm using the reachability API to detect my current connection, but I can only distinguish between WIFI and 3G.
I get the following flags:
LTE: kSCNetworkReachabilityFlagsIsLocalAddress|kSCNetworkReachabilityFlagsIsWWAN|kSCNetworkReachabilityFlagsTransientConnection|kSCNetworkReachabilityFlagsReachable
WIFI: kSCNetworkReachabilityFlagsIsDirect|kSCNetworkReachabilityFlagsReachable
The problem is that LTE returns the same flags as a 3G connection. Is there any way to determine whether the user currently has LTE or 3G?

As of iOS 7, you can find this out using the currentRadioAccessTechnology property of CTTelephonyNetworkInfo in the CoreTelephony framework.
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
if ([networkInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
// ...
}

I wonder if this hidden Core Telephony API can provide you with enough info for you to determine whether you're attached to an LTE or a slower technology.
CTRegistrationGetCurrentMaxAllowedDataRate();
It might be worth experimenting with.
More about using private APIs here: iPhone mobile number using Core telephony
However, I've read that your app will be rejected by apple if you use private APIs.

Related

Detect whether iPad supports sim card programmatically

Currently, I have an app that shows the 3G data / Wifi used by the user since the last reboot.
What I want to do is, if the app is running on an iPad which doesn’t support SIM card, I want to hide certain statistics shown to the user.
Is it somehow possible to detect whether the current iOS device supports a sim card or not?
As far as I know, you cannot detect if the SIM card is installed. You can only determine if a WWAN connection is available using Reachability or you can use CTCarrier
#import CoreTelephony;
-(BOOL)hasCellularCoverage
{
CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = [networkInfo subscriberCellularProvider];
if (!carrier.isoCountryCode) {
NSLog(#"No sim present Or No cellular coverage or phone is on airplane mode.");
return NO;
}
return YES;
}

How to check if Bluetooth is enabled via iOS External Accessory Framework?

I am writing an iOS-based program that interacts with a Bluetooth device via the External Accessory Framework. I would like to determine ahead of time if Bluetooth is even enabled before attempting to connect. Unfortunately, I don't see anything in the External Accessory Framework documentation that allows me to do this.
After checking the docs for the [EAAccessoryManager][1], the closest I can find is to check the [connectedAccessories][1] list to see if any devices are currently connected. However, this doesn't directly indicate the Bluetooth adapter's status.
There are plenty of examples on SO pertaining to Core Bluetooth and Bluetooth LE. I'm specifically looking for a solution related to the External Accessory Framework.
This is not possible with the ExternalAccessory framework. You should use CoreBluetooth, which can give you the information you need on devices that have BLE hardware, i.e. everything released after 2011. The fact that you are using ExternalAccessory for communication with your device does not prevent you from also using CoreBluetooth just for the purpose of knowing whether Bluetooth is turned on.
For older devices there is no way to get this info with public APIs, however if you are not intending to publish your app on the App Store you can use the private BluetoothManager framework.
To get the info with CoreBluetooth you will need to instanciate a CBCentralManager instance, for example like this :
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
and then implement the following delegate method to get the relevant info :
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
BOOL bleAvailable = central.state != CBCentralManagerStateUnsupported;
if (bleAvailable) {
BOOL bluetoothTurnedOn = central.state != CBCentralManagerStatePoweredOff;
// Do something with the info
}
else {
// Out of luck... We won't be able to determine whether BT is on or off
}
}

Get current type of internet connection

I want to get the technology of radio access (internet connection), so detect if the device is connected to Wifi or WWAN connection (and in this case, which type of WWAN : GPRS, EGDE, 3G, 3G+, 3G++, or 4G).
Does CTTelephonyNetworkInfo works for iPhone and iPad on iOS7.1 ?
I've tried to detect a Wifi connection on an iPad but I print a null result.
This is my code :
CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
NSLog(#"Current Radio Access Technology: %#", telephonyInfo.currentRadioAccessTechnology);
Someone can told me why ? I'm not sure to understand everything about this...
Thanks for your help
(Source : http://www.objc.io/issue-5/iOS7-hidden-gems-and-workarounds.html, section "Know your Radio")
That's because currentRadioAccessTechnology will return the radio access technology (not whether it's Wifi or WWAN). An example of return value is CTRadioAccessTechnologyLTE.
To get informed about whether your app is connect to Wifi or WWAN, you should use Reachability.
There are several implementations available.

Connecting to other Bluetooth Device by BeeTee app

I need to implement a self bluetooth app to connect with all bluetooth devices to iPhone. I know it is not possible with CoreBluetooth framework.
I use private API and added header files of DeviceManager and BluetoothManager to private frameworks and downloaded BeeTee Project from here
This app runs and finds all bluetooth device near me but when I have tried to connect to a device by this code:
[self.bluetoothManager connectDevice:bluetoothDevice];
and this
[bluetoothDevice connect];
When a cell is selected, Both of above codes request to connect but BTM returns this message:
BeeTee[5473:60b] BTM: connection to service 0xffffffff on device "Nokia 500" F4:xx:xx:xx:xx:xx failed with error 109
What is error 109? Which would be set service number?
I guess I should pair devices before connecting but how can I do that?
I am just guessing, but I think the problem is that the BluetoothManager.framework is made for the External Accessory Program by Apple. And this allows (among others) SPP Bluetooth connection to certificated devices. But there is the problem: you need to have a device with a authentication chip inside.
I don't know on which level/layer Apple implemented the authentication, but I fear the did it one layer under the private framework BeeTee is using.
UPDATE: Maybe this is helpful for you:
BluetoothManager *bluetoothManager = //...
[bluetoothManager setDevicePairingEnabled:YES];
[bluetoothManager connectDevice:bluetoothDevice withServices:0x00002000];
Credits
BluetoothManager *bluetoothManager = //...
[bluetoothManager setDevicePairingEnabled:YES];
[btManager setPincode:#"111111" forDevice:bluetoothDevice.deviceRef];
//where 111111 is your device PIN
[bluetoothManager connectDevice:bluetoothDevice withServices:0x00002000];

How to print out a list of currently connected bluetooth accessories in IOS

For an application I'm working on we are trying to log whether an iDevice is using an external GPS accessory such as the xgps. I've become a little confused exactly how to do this.
I understand there is a (NSArray *)retrieveConnectedPeripheralsWithServices:(NSArray *)serviceUUIDs call which might help but I'm unsure what to use for the serviceUUIDs and I couldn't really find much from the documentation. I understand I'm looking for A list of service UUIDs (represented by CBUUID objects).
Is there some sort of standardized list in the bluetooth Spec I should be using? I didn't see anything listing GPS here: http://bluetooth-pentest.narod.ru/doc/assigned_numbers_-_service_discovery.html
So in Summary:
In iOS 7 is there an easy way to query for connected bluetotooth devices and get information on them and if so could somebody provide a code sample?
Thanks
/* Store all the Bluetooth accessories currently connected */
NSArray *accessoryList = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];
for (EAAccessory *acc in accessoryList) {
// here you can do all your stuff by accessing acc
acc.firmwareRevision;
acc.hardwareRevision;
acc.manufacturer;
acc.modelNumber;
acc.serialNumber;
acc.name;
//etc
}
Larme pointed me to the link here: Display Bluetooth devices (Not BLE devices) in a UITableView
which specifies a call to:
NSArray* accessoryList = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];
which does the trick!

Resources