how to scan available beacons in my region iOS - ios

I am new to beacon coding.
Our client want a app which will scan all the available beacon devices (manufactured by client itself)
I want to write a generic code which will scan for all available devices near by, and will show me alert on particular command,
like it will blow GREEN light when call is there, Yellow light when Message received etc.
I have the commands provided, but need a methods for beacon to call those commands, in iOS.
first target is to scan all available devices.
On sample I found some tutorials which are providing direct UUID
but I need to generate a code which will scan all.
any links and other info is welcome.
Thanks in advance..

Apple restricts the ability to scan for iBeacons on iOS so that you must know the beacons' ProximityUUIDs up front. There is no way to simply scan for all iBeacons regardless of ProximityUUID using public APIs. While there are private API hacks that may allow this, these will not allow the app to be approved for distribution in the AppStore.
If you can get a finite list of known ProximityUUIDs for your client, this will still work OK. You can call CoreLocation's startRangingBeaconsInRegion: command multiple times, once for each ProxinityUUID. While there is no hard limit on the number of times you can call this (unlike monitoring APIs which have a limit of 20 regions), practically you can probably only call this in the low hundreds of times.
Bottom line: while you cannot scan for all beacons regardless of ProxinityUUID, you can get close to the same effect if you know all the UUIDs up front.

Related

How to scan ios apps in background or exchange data between two apps in background which simulate iBeacon advertising?

I would like to get notified when ios app is in range of other ios app even if they are both in the background mode. I know that I cannot advertise successully as a ibeacon after my ios app has gone to background because advertisement data is put in 'overflow' area. But the question is if we can extend the time that it is possible to advertise/simulate iBeacon? Are there any workarounds for this?
For example can I connect the devices in range by knowing their proximity UUID without user even knowing it? That would allow me exchange data between devices because my plan is that every user device will advertise with the same proximity UUID and the way I will identify users will be mix of major and minor ids.
Thanks in advance!
While iOS devices may not advertise iBeacon in the background, they can advertise what is known as the Overflow Area advertisement, which contains 128 bits of data. These Overflow Area advertisements are readable by backgrounded apps on other iPhones in the vicinity, provided those iPhones have their screen illuminated. (This happens even when phones are unused, as screens are typically illuminated briefly after a notification comes in.)
This makes it possible for one backgrounded iPhone app to read another backgrounded iPhone app's unique identifier passively in the background with no user interaction.
Advanced techniques are needed to configure Overflow Area advertisements, and to encode/decode unique identifiers inside them. Fortunately, I wrote up a detailed blog post of how this works, and created an open-source reference app you can use as a starting point to building your own app. This way, you don't need to master the complexities yourself to get this working.
If you build and run the reference app on two iPhones, it will assign a unique numeric identifier to each phone, and then you will see that Phone A detects the unique identifier of phone B and vice versa.

How to prevent cloning in Ibeacons and avoid conflicts among beacons?

I am trying to develop one app with using a lot of beacons like say in any muti floor shopping mall. In this situation how can I control these
Suppose someone clones a beacon and starts advertsing the signal with same UUID, major, and minor, how to prevent that and what are the other security measures that can be taken?
How to avoid mutiple notifications, suppose somewhere conflicted by two beacons any area is common to more than one beacons, how to control that in app?
The iBeacon standard does not provide any built-in ways to prevent cloning. Apple restricts iOS devices from seeing iBeacons except for ones where the ProximityUUID is known, suggesting this may have been a rudimentary security attempt. But since other operating systems (Android, OSX Mavericks, Linux) allow reading identifiers of all iBeacons, this restriction seems rather silly. It is possible to read identifiers using a tool like Android iBeacon Locate and deploy your own iBeacon with the same identifiers.
Four common approaches to address this:
Do nothing. This is appropriate for most use cases where cloned beacons will cause minor consequences or for low profile deployments where the risk of someone doing this is minimal.
Rotate the iBeacon identifiers. You can do this manually by replacing beacons or manually changing their identifiers periodically. This does not eliminate the problem, but it limits the risk and impact on time.
Use an automated rotating identifier combined with an automated system for validating/converting it to a trusted identifier.
Abandon the iBeacon standard and use a proprietary beacon technology using encryption. This should be considered a last resort, because this choice makes it impossible to use widely available open source and commercial tools for working with iBeacons, and locks you into a single vendor.
Before you choose any option other than the first, be sure you carefully evaluate the risk and consequences of cloning, and be sure any countermeasure you take is really worth the downsides.
The multiple notification problem described in the question is generally not an issue in the absence of intentional cloning. Simply design the ProximityUUID/major/minor numbers of your beacons to be unique for each event you wish to give to users and make your app respond appropriately.
For beacon clone:
customize your beacon firmware and encrypt major/minor with a random key. If beacon and app both can access to cloud, maybe exchange random key via cloud to encrypt/decrypt the major/minor id. If no cloud is involved, beacon and app need to deal with a random key generating algorithm, ex use time as a seed.
(Encrypt with a forever fixed key is useless because clone or replay beacon advertising data still can cheat app)
Rotate UUID with a predefined table-based list. This just reduces the risk with a periodically changing UUID but not really fix the security issue. And the UUID list has a limited size because all UUIDs in list may need to pre-register in App, ex iOS, to let iOS take it as a recognized region and then pass data to your App.
For Multi-notification:
Usually, this should be handled by App.
When enter a region or beacon trigger callback, app should check if it is a duplicated region by uuid-major-minor info. App should also check if it is related notification/info has been sent to user or not to avoid user be bothered by duplicated notification.

Accessing battery level of battery powered iBeacon devices (mainly kontakt io ones)?

I am trying to find a way to access the battery levels from my beacons through an iOS application I am currently working on. I am using Kontakt's iBeacon devices. I browsed the Estimote iOS SDK and they provide a method to achieve this. I was wondering if it is at all able to access the raw beacon packet and manually extract the data since I know the beacon packet structure and the information is there.
Any thoughts on how to achieve this by the method mentioned here or any other way?
Thanks Guys.
This is Rafal from kontakt.io. Firstly, let me thank you for choosing us, it means a lot for us.
Propagation of battery level is not standard for iBeacons nor it is in any official iBeacon documentation, so that is why you cannot find the value using custom SDKs. Our iBeacons are propagating battery level in scan response packet which may be discovered using CoreBluetooth API in iOS. The level is one byte value at the 23rd byte in the packet.
Hope it helps :)
As far as I am aware there is nothing in the iBeacon advertisement itself that contains the battery level. Some beacons may expose additional BLE ATT services that contain this information. You could try using an application like LightBlue from the app store to explore the services available from your devices

Check if iDevice with a specific app is nearby

Is it possible to check within an app, if there are other idevices nearby which have the app running?
For example device A starts the app. Device B also starts the app. When they are nearby, a notification will popup.
I know its possible to check the range between two GPS coordinates. But the only solution that I've found on the internet was, that I have to make a webservice/server which handles the coordinates which were sent by the idevices.
But I'd like to make it run "offline", without saving/sending the data at a webserver.
You can achieve exactly this using the new iBeacons functionality in iOS 7. I'm not sure I can link to the exact documentation due to the NDA currently (although the feature was mentioned publicly at WWDC), but if you search for 'beacons' on the Apple Developer site you should find what you need.
There are also some examples towards the end of this year's WWDC session 307 - "What's new in Core Location?". This is arguably more useful than the documentation.
Essentially, you define a beacon region and tell your devices to start advertising their presence. At the same time, you can listen out for beacons in the local area - CoreLocation will then report you the identifier and approximate distance of each device.

How to check if another iPhone using the same program is in your vicinity?

I've been googling this problem, but haven't gotten the wording right.
Basically I'm looking for an API, or some seeds of guidance in how I would go about writing a program where you get push notified if someone is in the same area as you based on GPS coordinates. In short: a realtime 4square not based on checking-in but based on GPS.
Part of me feels like this is something Apple may frown upon, but if the user is notified and making the decision to run the app, perhaps not.
Thanks in advance.
You're looking for the Bluetooth Bonjour type notifications found in GameKit. This has nothing to do with GPS and is instead based of short range radio (Bluetooth) which advertises itself using a zero conf protocol. The APIs basically give you the ability to broadcast your service (eg. "MyGame") over bluetooth and listen for others potentially broadcasting the same service.
If you're talking about geographic vicinity, you'll need to set up a central server where each device can register its location, and which will provide locations of nearby devices. A service like FourSquare does exactly this kind of thing.
Another way to look at 'vicinity' is network vicinity. You could have each device advertise itself via Bonjour and look for other devices doing the same.

Resources