expofp / expofp-sdk-ios

IOS SDK
MIT License
0 stars 0 forks source link

ExpoFP Fplan - iOS library for displaying expo plans

Create your expo plan on the website https://expofp.com then use the URL of the created expo plan when you working with the library

WhatsApp Image 2022-01-05 at 22 51 07

Table of Contents

Version for Android

https://github.com/expofp/expofp-android-sdk

Usage example

https://github.com/expofp/expofp-swiftui-example

3.0.1 version

What's New in ExpoFP Fplan version 3.0.1

Navigation from CrowdConnected and IndoorAtlas has been added.

Installation

Cocoapods:

pod 'ExpoFpFplan', '3.0.1'

Usage

import SwiftUI
import ExpoFpFplan

@main
struct FplanApp: App {

    var fplanView = FplanView()

    var body: some Scene {
        WindowGroup {
            VStack
            {
                fplanView.onAppear{
                    fplanView.load("https://demo.expofp.com")
                }
                .onDisappear {
                    fplanView.destoy()
                }
            }
        }
    }
}

Stop FplanView.
After you finish working with FplanView, you need to stop it.
To do this, you need to call the 'destroy' function:

fplanView.destoy()

Functions

Open plan:

fplanView.load("https://demo.expofp.com")

Stop FplanView:

fplanView.destoy()

Select booth:

fplanView.selectBooth("720")

Build route:

fplanView.buildRoute(Route(from: "720", to: "751", exceptInaccessible: false))

Set current position(Blue-dot):

fplanView.setCurrentPosition(BlueDotPoint(x: 22270, y: 44900), true)

Clear floor plan:

fplanView.clear()

Events

Floor plan ready event:

import SwiftUI
import ExpoFpFplan

@main
struct FplanApp: App {

    var fplanView = FplanView()

    var body: some Scene {
        WindowGroup {
            VStack
            {
                fplanView.onFpReady{
                    print("[Fplan] - fpReady")
                }
                .onAppear{
                    fplanView.load("https://demo.expofp.com")
                }
                .onDisappear {
                    fplanView.destoy()
                }
            }
        }
    }
}

Select booth event:

import SwiftUI
import ExpoFpFplan

@main
struct FplanApp: App {

    var fplanView = FplanView()

    var body: some Scene {
        WindowGroup {
            VStack
            {
                fplanView.onBoothClick{ boothName in
                    print("[Fplan] - select booth \(boothName)")
                }
                .onAppear{
                    fplanView.load("https://demo.expofp.com")
                }
                .onDisappear {
                    fplanView.destoy()
                }
            }
        }
    }
}

Route create event:

import SwiftUI
import ExpoFpFplan

@main
struct FplanApp: App {

    var fplanView = FplanView()

    var body: some Scene {
        WindowGroup {
            VStack
            {
                fplanView.onBuildDirection { direction in
                    print(direction)
                }
                .onAppear{
                    fplanView.load("https://demo.expofp.com")
                }
                .onDisappear {
                    fplanView.destoy()
                }
            }
        }
    }
}

Navigation

There are 2 ways to use navigation in FplanView. The first way is to explicitly specify the provider. In this case, FplanView will start and stop the LocationProvider on its own.

let locationProvider: LocationProvider = ...
fplanView.load(state.url, noOverlay: false, locationProvider: locationProvider)

The second way is to run the GlobalLocationProvider when the program starts:

let locationProvider: LocationProvider = ...
GlobalLocationProvider.initialize(locationProvider)
GlobalLocationProvider.start()

Using the GlobalLocationProvider in the FplanView:

fplanView.load(state.url, noOverlay: false, useGlobalLocationProvider: true)

When the program terminates, the GlobalLocationProvider must also be stopped:

GlobalLocationProvider.stop();

CrowdConnected location provider

Сocoapods:

pod 'ExpoFpCrowdConnected', '3.0.1'

Import:

import ExpoFpCrowdConnected

Initialization:

let locationProvider: LocationProvider = CrowdConnectedProvider(Settings("APP_KEY", "TOKEN", "SECRET"))

Aliases:

let settings = ExpoFpCrowdConnected.Settings("APP_KEY", "TOKEN", "SECRET")
settings.addAlias("KEY_1", "VALUE_1")
settings.addAlias("KEY_2", "VALUE_2")
let locationProvider: LocationProvider = CrowdConnectedProvider(settings)

IndoorAtlas location provider

Сocoapods:

pod 'ExpoFpIndoorAtlas', '3.0.1'

Import:

import ExpoFpIndoorAtlas

Initialization:

let locationProvider: LocationProvider = IndoorAtlasProvider(Settings("API_KEY", "API_SECRET_KEY"))