This sample app demonstrates how to integrate AWS Location Service with an iOS application using Amazon Cognito for authentication and tracking location updates in real-time. It showcases the usage of Amazon Location Service's Tracking and Authentication SDKs to authenticate users and track their location on a map.
Additional documentation for this sample application is available from the Amazon Location Service documentation website.
- Tracking SDK: Amazon Location Service Tracking SDK
- Auth SDK: Amazon Location Service Authentication SDK
- Clone this repository to your local machine.
- Open
AWSLocationSampleApp.xcodeproj
project in Xcode. - Build and run the app on your iOS device or simulator.
- Open
ConfigTemplate.xcconfig
file - Copy contents to a new file named
Config.xcconfig
- Configure AWS credentials in the app using one of the following methods:
- Option 1. Configure via Config.xcconfig: Fill in the required values in the
Config.xcconfig
file to configure the AWS credentials. (Refer to the Configuration section for details) - Option 2. Configure via app: Upon launching the app, navigate to the Config tab and enter your AWS Identity Pool ID, Map Name, Tracker Name and Geofence Collection ARN to configure the AWS credentials.
A template configuration file named ConfigTemplate.xcconfig
is included in the root of the project. To use it:
- Copy
ConfigTemplate.xcconfig
file toConfig.xcconfig
. - Fill in the following values in
Config.xcconfig
:
IDENTITY_POOL_ID = [Your Cognito Identity Pool ID]
MAP_NAME = [Your Map Resource Name]
TRACKER_NAME = [Your Tracker Resource Name]
GEOFENCE_ARN = [Your Geofence Collection ARN]
WEBSOCKET_URL = [Your IoT WebSocket URL]
- IDENTITY_POOL_ID: Your AWS Cognito Identity Pool ID used for authenticating users.
- MAP_NAME: The name of the map resource in Amazon Location Service you want to use for displaying the map.
- TRACKER_NAME: The name of the tracker resource in Amazon Location Service used for tracking location updates.
- GEOFENCE_ARN: The Amazon Resource Name (ARN) of your geofence collection in Amazon Location Service. (Optional)
- WEBSOCKET_URL: The WebSocket URL used for geofence monitoring. (Optional)
These values are used to configure the app's connection to AWS services. If not provided in the Config.xcconfig
file, they can be filled out manually in the app's Config tab.
The app provides options to filter location tracking data based on time, distance, and accuracy:
- Time Filter: If enabled, location updates are sent only after the specified time interval has passed.
- Distance Filter: If enabled, location updates are sent only after moving a specified distance from the last reported location.
- Accuracy Filter: If enabled, location updates are filtered based on the specified accuracy level.
These filters help in optimizing the location tracking to suit different use cases and requirements.
In order to run the UI tests, you need to provide the AWS credentials in the TestConfig.xcconfig
file.
- Copy
TestConfigTemplate.xcconfig
file toTestConfig.xcconfig
. - Fill in the following values in
TestConfig.xcconfig
:
TEST_IDENTITY_POOL_ID = [Your Cognito Identity Pool ID]
TEST_MAP_NAME = [Your Map Resource Name]
TEST_TRACKER_NAME = [Your Tracker Resource Name]
TEST_WEBSOCKET_URL = [Your IoT WebSocket URL]
TEST_GEOFENCE_ARN = [Your Geofence Collection ARN]
- Run the UI tests by selecting the
AWSLocationSampleAppUITests
target and selecting Product -> Test from the Xcode menu.