SDK for iOS Developer's Guide

Offline Search

Force Online or Offline

You can launch online or offline search without changing the device or HERE SDK connectivity by using connectivity property on an NMARequest instance. This property is applicable to all NMARequest subclasses except NMAAutoSuggestionRequest, which can only be used online.

Note: In HERE SDK v3.4 we have updated the behavior of the routing connectivity modes (NMARequestConnectivity) to be more consistent with other parts of the SDK.
connectivity property can be set to three possible values:
  • If you launch a request using NMARequestConnectivityDefault connectivity mode, the request is performed according to NMAApplicationContext connectivity setting. If the device is offline while NMAApplicationContext is set to online mode, the request fails.
  • If you launch a request using NMARequestConnectivityOnline connectivity mode, an online request is performed regardless of NMAApplicationContext connectivity setting.
  • If you launch a request using NMARequestConnectivityOffline connectivity mode, an offline request is performed regardless of NMAApplicationContext connectivity setting.
In all cases if the request fails, no fallback action is automatically performed.

To ensure that the connectivity mode is applied, set connectivity property before executing an NMARequest.

Depending on your search request and the connectivity mode you can get a few different errors:

  • If an NMARequestConnectivityOnline search request fails due to connection issues, HERE SDK returns NMARequestErrorUnknown error code.
  • If an NMARequestConnectivityOnline Geocoding or Reverse Geocoding request fails due to connection issues, HERE SDK returns NMARequestErrorNetworkCommunication error code.
  • If an NMARequestConnectivityOffline search request fails due to not enough cached data, HERE SDK returns zero results.
  • If you attempt to start an NMAAutoSuggestionRequest with NMARequestConnectivityOffline connectivity mode, HERE SDK returns NMARequestErrorNotSupported error code since auto suggestions are only supported online.