Giter Site home page Giter Site logo

luna_ios_sdk's Introduction

Luna SDK iOS

splash-icon

Luna SDK is an iOS framework for working with Luna Trackers. For more information check Luna webpage. โ€‹

Installation

Luna SDK is entirely standalone and does not depend on any third party libraries. The easiest way to integrate Luna SDK with the host application is via CocoaPods (CocoaPods version 1.11.3 suggested).

Please add pod 'LunaSDK', :git => '[email protected]:indigo-d/luna_ios_sdk.git' to your Podfile, example:

  # Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
    pod 'LunaSDK', :git => '[email protected]:indigo-d/luna_ios_sdk.git'
end

Execute pod install so that CocoaPods fetches and links Luna SDK with your project.

Prerequisites

In order for Luna SDK to function correctly, the developer of the host application needs to ensure that the host app includes required background mode settings and requests user permission to access location, etc.

Project settings

LunaSDK requires a few configuration steps that need to be taken by the developer of the host application.

  1. Location updates in the Background Modes - UIBackgroundModes of type location need to be defined in host app Info.plist file. See example below:
<key>UIBackgroundModes</key>
<array>
    <string>location</string>
</array>
  1. Request Always Authorization for the location updates - in order for registering for iBeacon events when the application is not actively running the host app needs to be authorized by the user to fetch user location always. Developer of the host application should request user permission before initiating LunaSDK.

Basic usage

Insert gif or link to demo

import UIKit

// 1
import LunaSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    // 2
    let mqttHost = "your mqqt host"

    // 3 
    let configuration = LunaConfiguration(mqttHost: mqttHost)

    // 4
    let luna = Luna.finder(configuration)
        
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // 5
        luna.delegate = self
        
        // 6
        luna.start()
        
        return true
    }
}

// 7
extension AppDelegate: LunaDelegate {

    func lunaFinder(didFailWithError error: Error) {
        print(error.localizedDescription)
    }
    
    // optional
    func lunaFinder(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
        print(region)
    }
    
    // optional
    func lunaFinder(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
        print(region)
    }
    
    // optional
    func lunaFinder(didFindHeid heid: String) {
        print(heid)
    }
}
  1. Import Luna SDK.
  2. Set your MQTT host path.
  3. Set your basic configuration with MQTT host path
  4. Initialize LunaFinder object with basic configuration
  5. Delegate for the Luna is set. Conformance to the LunaDelegate protocol is set in the extension of the AppDelegate.
  6. Start function is called. After that we can receive informations about trackers in range.
  7. In the AppDelegate extension, conformance to the LunaDelgate protocol is set.

luna_ios_sdk's People

Contributors

tomaszlizer avatar rodykow-bright avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.