Service

public protocol Service

Used to connect to the Mappedin servers and retrieve venue data a Service once implemented is used to hold the apiKey’s and Venue type required to use the Mappedin SDK

  • Example:

      class ExampleService: Mappedin.Service {
          typealias VenueType = Venue
    
          let apiKey = "<key>"
          let apiSecret = "<secret>"
          let dataKey = "<data>"
    
          required init() {}
      }
    
      // It's important to have this step, this will modify the AppDelegate
      // to include Mappedin's analytics frameworks, your service will not
      // function if you do not install this. 
      public let service = ExampleService(AppDelegate.self)
    
      // With that created, we can now initialized, we can call the Mappedin
      // API in order to get the required data from our servers.
      service.getVenues()
         .onComplete{ venues in
             // find your venue from the list of venues that
             service.getVenue(venues.first!).onComplete { venue in
                 // With a venue loaded we can setup the MapView
                 // but that will be shown in another example.
             }
          }
    
  • This is which Venue object to deserilize when we download a venue from the Mappedin servers. This VenueType will be supplied by Mappedin when you are granted access to the SDK.

    Declaration

    Swift

    associatedtype VenueType : Venue
  • A unique key used to identify your account with Mappedin. Supplied when you sign up for the Mappedin SDK

    Declaration

    Swift

    var apiKey: String { get }
  • Used to authenticate that your app. Supplied when you sign up for the Mappedin SDK

    Declaration

    Swift

    var apiSecret: String { get }
  • Used to uniquely identify what type of Map data to download. Supplied when you sign up for the Mappedin SDK

    Declaration

    Swift

    var dataKey: String { get }
  • searchUser Default implementation

    The search user, provided by your Mappedin Rep

    if these are not supplied, the search functionality will not work but the rest of the SDK will continue to function.

    Default Implementation

    Declaration

    Swift

    var searchUser: String { get }
  • searchKey Default implementation

    The search key, provided by your Mappedin Rep

    if these are not supplied, the search functionality will not work but the rest of the SDK will continue to function.

    Default Implementation

    Declaration

    Swift

    var searchKey: String { get }
  • The default constructor for your service.

    Declaration

    Swift

    init()
  • init(_:) Extension method

    This must be called when initializing your Service.

    This will wrap your Application Delegate allow the Mappedin API to intercept some message that are sent form the system. This is required in order to implement some aspects of the API.

    Note

    This should only be done once, in the scope of your App. You should save your unique service object as a global variable. This follows the Singleton pattern.

    Declaration

    Swift

    init(_ appDelegateType: UIApplicationDelegate.Type)

    Parameters

    appDelegateType

    Your Application’s Delegate object

  • getVenues() Extension method

    Retrieves a list of all venues your credentials have access to

    Declaration

    Swift

    func getVenues() -> APIRequest<[VenueListing]>
  • getVenue(_:languageCode:) Extension method

    Retrieves the full details (maps, locations, etc) of a given venue

    Declaration

    Swift

    func getVenue(_ venueListing: VenueListing, languageCode: String? = nil) -> APIRequest<VenueType>

    Parameters

    venueListing

    The specific venue that you are requesting the data for

    languageCode

    The language to use when getting venue data, if available. If the language code provided is not available for the venue, getVenue will try to find a suitable language based on the device’s language settings, and use the venue’s preferred language if no suitable match is found.

    Return Value

    An APIRequest that will contain the future results after they have been downloaded and decoded from the Mappedin servers.

    • Note: It is important to populate the onError handler because your logic will miss any error that might be caused by the API key misconfiguration.