Skip to content

Around Me iOS

💻 Setup

In your project, add the following lines to your Podfile:

source 'https://github.com/CocoaPods/Specs.git' # Default Cocoapods URL
source 'https://github.com/hove-io/Podspecs.git' # Around Me podspec URL

target 'YOUR_PROJECT_SCHEME' do
  pod 'AroundMeSDK', '3.10.2' # Around Me Pod definition
end

# Required for XCFramework
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
  end
end

Using your CLI, run pod install in your project directory.

👨‍💻 Implementation

Warning

Make sure to read the modules configuration section before proceeding

This module is set up by calling AroundMe.shared.initialize() method which takes the following parameters:

Name Required Description Type Example
coverage Navitia coverage String fr-idf
env Navitia environment String PROD
colors Define the custom colors AroundMeColorsConfiguration -
fonts Use custom fonts AroundMeFontsConfiguration -
lineResources List of transport lines resource IDs [LineResource] -
modeResources List of transport modes resource IDs [ModeResource] -
transportCategories List of supported transport modes [TransportCategory] -
poiCategories List of available POIs [PoiCategory] -
providerResources Transport providers configuration [ProviderResource] -
titleResources Screens titles customization AroundMeTitlesResources -
features Enable/disable some features AroundMeFeaturesConfiguration -

You can also call the initialize() method with the global JSON configuration file added to your application bundle:

Name Required Description Type Example
configurationJsonFile Global configuration JSON file name String configuration.json

Example

do {
    try AroundMe.shared.initialize(
        token: "your_token", 
        configurationJsonFile: "aroundme_configuration.json"
    )                                                               
} catch {
    Logger.error("%@", String(
        format: "Around Me SDK cannot be initialized! %@", 
        error.localizedDescription)
    )
}                                   
do {
    let transportCategories = [TransportCategory(
        modules: ["aroundme"],
        iconRes: "ic_section_mode_metro",
        nameRes: "metro",
        selected: true,
        modes: [TransportCategoryMode(
            physical: TransportPhysicalMode(
                id: "physical_mode:Metro", 
                nameRes: "metro"
            ),
            commercial: TransportCommercialMode(
                id: "commercial_mode:Metro", 
                name: "Metro"
            )
        )],
        firstSectionModes: ["walking"],
        lastSectionModes: ["walking"]
    )]
    let aroundmeColorsConfiguration = AroundMeColorsConfiguration(
        primaryColor: "#88819f", 
        secondaryColor: "#8faa96"
    )

    try AroundMe.shared.initialize(
        coverage: "fr-idf",
        token: "your_token",
        env: "PROD",
        colors: aroundmeColorsConfiguration,
        transportCategories: transportCategories
    )                                                                  
} catch {
    Logger.error("%@", String(
        format: "Around Me SDK cannot be initialized! %@", 
        error.localizedDescription
    ))
}                                   

Events tracking

In order to receive the list of generated events within Around Me module, you have to assign the instance of the tracker to the Around Me module instance as follows and implement the required methods:

AroundMe.shared.tracker = self

🚀 Launching

This module has a single entry point. The parameter showBack handles the back button visibility on the first screen.

guard let aroundMeViewController = AroundMe.shared.rootViewController else {
    return nil
}
aroundMeViewController.showBack = false // Hide back button embedded in the first screen

If you want to use the rootViewController as a ChildViewController of your ViewController, you should embed it in an NavigationController.

navigationController?.pushViewController(
    trafficViewController,
    animated: false
)
yourViewController.addChild(UINavigationController(
    rootViewController: trafficViewController
))

Filters

This screen content is a visual version of the passed transport categories and POI categories configuration (check modules configuration section for more information). The selected elements will be used to filter the data received and drawn within the map. One filter should at least be selected or else the user can't apply the current filters configuration.

If you want to reset the user filters configuration, you can simply call AroundMeUI.getInstance().resetUserPreferences() and the current configuration will be deleted and the screen will be updated according to the new passed configuration.

📣 Communicating with other modules or the app

Around Me module can exchange data with or navigate to either other modules or the host application.
To do this, the host application must initialize Router. This singleton will ensure communication between the different modules or the app. Communication will not occur unless those are registered beforehand:

try Router.shared
    .register(aroundMe: AroundMe.shared.aroundMeRouter)
    ... // Register modules and/or app
    .initialize()

Modules

Bookmark

Enabling

Around Me module communicates with Bookmark module in order to vizualize favorite stations, journeys and POIs. You should enable the bookmark_mode parameter in the features configuration.

Bookmark module must be registered in the Router to build the connection between these modules:

Router.shared.register(bookmark: Bookmark.shared.bookmarkRouter)

Methods

The following methods from the CustomAroundMeBookmarkDelegate interface should be implemented by the host application to enable navigation to the Bookmark module or any other custom screen. Note that the parameters of these methods can be omitted as needed.

Warning

If you don't implement this protocol, the Bookmark module will be shown.

This method is called after click on the favorite home shortcut button, in case it is empty.

func onHomeAddressCompletionRequested(module: Router.BookmarkLinkedModule) {
    // launch the bookmark module screen or your custom screen
}

Param Type Description Value
module Router.BookmarkLinkedModule Module triggering the method call Router.BookmarkLinkedModule.aroundMe or Router.BookmarkLinkedModule.journey

This method is called after click on the favorite work shortcut button, in case it is empty.

func onWorkAddressCompletionRequested(module: Router.BookmarkLinkedModule) {
    // launch the bookmark module screen or your custom screen if the favorite work address is empty
}
Param Type Description Value
module Router.BookmarkLinkedModule Module triggering the method call Router.BookmarkLinkedModule.aroundMe or Router.BookmarkLinkedModule.journey
func onSeeAllFavoritesClicked() {
    // launch the bookmark module screen or your custom screen
  }

Journey

Enabling

Around Me module communicates with Journey module in order to get directions for a chosen itinerary. You should enable the journey_mode and the go_from_go_to parameter in the features configuration.
Another way to communicate with is through the Map screen and precisely the Where are we going? button, this feature should also be enabled by setting the where_shall_we_go in the features configuration to true.

Journey module must also be registered in the Router to build the connection between these modules:

Router.shared.register(journey: JourneySdk.shared.journeyRouter)

Traffic

Enabling

Around Me module communicates with Traffic module in order to easily access traffic information. You should enable the traffic_mode parameter in the features configuration.

Traffic module must also be registered in the Router to build the connection between these modules:

Router.shared.register(traffic: Traffic.shared.trafficRouter)