The iOS SDK for Nearspeak.
- Fetch Nearspeak tag informations from the Nearspeak server
- Query for Nearspeak iBeacons
- iOS 8.0+
- Xcode 6.3
You can use CocoaPods to install NearspeakKit
by adding it to your Podfile
:
use_frameworks!
pod "NearspeakKit", :git => "https://github.com/nearspeak/iOS-SDK.git"
Note that CocoaPods version >= 36 is required and iOS deployment target >= 8.0
[sudo] gem install cocoapods -v ">=0.36"
You can use Carthage to install NearspeakKit
by adding it to your Cartfile
:
github "nearspeak/iOS-SDK" ~> 0.9
To discover iBeacon Nearspeak tags your app requires the following keys setup in your Info.plist
:
- NSLocationAlwaysUsageDescription
In your Swift Class import NearspeakKit
to use the NearspeakKit
Start listening to tag update notifications.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "onNearbyTagsUpdatedNotification:", name: NSKConstants.managerNotificationNearbyTagsUpdatedKey, object: nil)
Implement a function, which gets called if one or more tags are discovered.
func onNearbyTagsUpdatedNotification(notification: NSNotification) {
// refresh the table view
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.reloadData()
print("Found \(NSKManager.sharedInstance.nearbyTags.count) tags")
})
}
You can access the nearby tags array via NSKManager.sharedInstance.nearbyTags
.
Now start the beacon discovery.
NSKManager.sharedInstance.startBeaconDiscovery(true)