Latest 1.1.3
Homepage https://github.com/Beaconstac/NearBee-iOS-SDK
License MIT
Platforms ios 10.0, requires ARC
Dependencies EddystoneScanner, Socket.IO-Client-Swift
Frameworks CoreData, SystemConfiguration, CoreBluetooth, CoreLocation, UserNotifications, SafariServices
Authors

NearBee SDK for iOS

Introduction

NearBee SDK is an easy way to enable proximity marketing through an Eddystone-compliant BLE network.

Installation

Using Cocoapods (recommended):

Add the following to your Podfile in your project, we are supporting iOS 10.0+ make sure your pod has proper platform set.

platform :ios, '10.0'
target '<My-App-Target>''
  pod 'NearBee'
end

Run pod install in the project directory

Manually:

  1. Download or clone this repo on your system.
  2. Drag and drop the NearBee.framework file into your Xcode project. Make sure that "Copy Items to Destination’s Group Folder" is checked.
  3. Add the NearBee.frameworkm EddystoneScanner.framework and Socket.IO-Client-Swift.framework to the embedded binaries section of your destination app target.

  4. In Build Phases under destination app target, add the following frameworks in Link Binary With Libraries section:
    • CoreData.framework
    • SystemConfiguration.framework
    • CoreBluetooth.framework
    • CoreLocation.framework
    • EddystoneScanner.framework
    • NearBee.framework
    • Socket.IO-Client-Swift.framework

Configure your project

  1. In Info.plist, add a new fields, NSLocationAlwaysUsageDescription, NSLocationAlwaysAndWhenInUsageDescription, NSBluetoothPeripheralUsageDescription with relevant values that you want to show to the user. This is mandatory for iOS 10 and above.

Pre-requisite

Location

The app should take care of handling the permissions as required by your set up to receive notifications on entring the beacon region.

Bluetooth

The app should take care of enabling the bluetooth to range beacons.

MY_DEVELOPER_TOKEN

The app should provide the developer token while initializing the SDK. Get it from Beaconstac Dashboard Account Page.

__MY_ORGANIZATION__

The app should provide the organization while initializing the SDK. Get it from Beaconstac Dashboard Account Page.

Monitoring Regions

If you are using the region monitoring API’s from advanced location manager, make sure it won’t affect the NearBee SDK.

Set Up

  1. In the app’s Info.plist add the below mentioned keys and the values
    <key>co.nearbee.api_key</key>
    <string>__MY_DEVELOPER_TOKEN__</string>

    <key>co.nearbee.organization_id</key>
    <string>__MY_ORGANIZATION__</string>
  1. Import the framework header in your class
import NearBee
import <NearBee/NearBee.h>
  1. Initialize NearBee using one-line initialization, the initialization starts scanning for beacons immediately.
var nearBee = NearBee.initNearBee()
NearBee *nearBee = [NearBee initNearBee];
  1. If you wish to control start and stop of scanning for beacons:
nearBee.startScanning() // Starts scanning for beacons...
nearBee.stopScanning() // Stops scanning for beacons...
[nearBee startScanning];
[nearBee stopScanning];
  1. Implement NearBeeDelegate protocol methods to show the beacons either in UITableView or UICollectionView
func onBeaconsFound(_ beacons: [NearBeeBeacon]) {
    // Display Beacons
}

func onBeaconsUpdated(_ beacons: [NearBeeBeacon]) {
    // Display Beacons
}

func onBeaconsLost(_ beacons: [NearBeeBeacon]) {
    // Display Beacons
}

func onError(_ error: Error) {
    // Show Error
}
- (void)onBeaconsUpdated:(NSArray<NearBeeBeacon *> * _Nonnull)beacons {
    // Display Beacons
}

- (void)onBeaconsLost:(NSArray<NearBeeBeacon *> * _Nonnull)beacons {
    // Display Beacons
}

- (void)onBeaconsFound:(NSArray<NearBeeBeacon *> * _Nonnull)beacons {
    // Display Beacons
}

- (void)onError:(NSError * _Nonnull)error {
    // Error
}
  1. Once user clicks on the notification, pass it to the NearBee SDK to display the notificaiton

// In the class where you want to listen to notification events...
let nearBeeInstance = try! NearBee.sharedInstance()
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    let isNearBeeNotification = nearBee.checkAndProcessNearbyNotification(response.notification)
    if (isNearBeeNotification) {
        completionHandler()
    } else {
        // Not a near bee notification, you need to handle
    }
}

// In the class where you want to listen to notification events...
NSError *error = nil;
NearBee *nearBeeInstance = [NearBee sharedInstanceAndReturnError:&error];

- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)(void))completionHandler {

    BOOL isNearBeeNotification = [nearBee checkAndProcessNearbyNotification: response.notification];
    if (isNearBeeNotification) {
        completionHandler()
    } else {
        // Not a near bee notification, you need to handle
    }
}

Latest podspec

{
    "name": "NearBee",
    "swift_version": "4.2",
    "version": "1.1.3",
    "summary": "iOS library for Eddystone beacons",
    "homepage": "https://github.com/Beaconstac/NearBee-iOS-SDK",
    "authors": {
        "MobStac Inc.": "[email protected]"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "source": {
        "git": "https://github.com/Beaconstac/NearBee-iOS-SDK.git",
        "tag": "v1.1.3"
    },
    "xcconfig": {
        "LIBRARY_SEARCH_PATHS": "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"
    },
    "vendored_frameworks": "NearBee/NearBee.framework",
    "dependencies": {
        "EddystoneScanner": [],
        "Socket.IO-Client-Swift": []
    },
    "frameworks": [
        "CoreData",
        "SystemConfiguration",
        "CoreBluetooth",
        "CoreLocation",
        "UserNotifications",
        "SafariServices"
    ],
    "requires_arc": true,
    "platforms": {
        "ios": "10.0"
    }
}

Pin It on Pinterest

Share This