Welcome to the documentation for FRDStravaClient, a powerful iOS client for the Strava API. This library provides an easy-to-use interface for authenticating users, making requests, and accessing data from the Strava API.
Features
- Simple integration with the Strava API
- Easy authentication process
- Effortlessly retrieve activity data
- Submit activities directly from your app
FRDStravaClient simplifies the process of integrating Strava functionality into your iOS app. Whether you’re building a fitness tracking app, a social fitness app, or any other app that requires access to Strava data, this library has you covered.
Installation Guide
To get started with FRDStravaClient, follow these steps:
Step 1: Add dependency to your project
In your `Podfile`, add the following line:
“`ruby
pod ‘FRDStravaClient’
“`
Step 2: Install dependencies
Run the following command in your project directory:
“`bash
pod install
“`
Usage Guide
Authentication
FRDStravaClient provides an easy way to authenticate users with the Strava API. Follow these steps to authenticate a user:
- Create an instance of `StravaAuthenticator`.
- Call `authenticate` method on the `StravaAuthenticator` instance.
- Present the authentication UI to the user and handle the callback.
Example code:
“`swift
let authenticator = StravaAuthenticator(clientId: “YOUR_CLIENT_ID”, clientSecret: “YOUR_CLIENT_SECRET”, redirectURL: “YOUR_REDIRECT_URL”)
authenticator.authenticate(presentingViewController: self) { result in
switch result {
case .success(let token):
// Authentication successful, use the `token` to make API requests
case .failure(let error):
// Authentication failed, handle the error
}
}
“`
Examples
Retrieve Activity Data
Once authenticated, you can retrieve activity data from the Strava API using the `StravaClient` class. Here’s an example:
“`swift
let stravaClient = StravaClient(accessToken: “YOUR_ACCESS_TOKEN”)
stravaClient.retrieveActivity(id: “YOUR_ACTIVITY_ID”) { result in
switch result {
case .success(let activity):
// Activity data retrieved successfully, use the `activity`
case .failure(let error):
// Failed to retrieve activity data, handle the error
}
}
“`
Submit an Activity
If your app allows users to submit activities to Strava, you can use the `StravaClient` class to submit activities. Here’s an example:
“`swift
let stravaClient = StravaClient(accessToken: “YOUR_ACCESS_TOKEN”)
let activity = StravaActivity(name: “My Run”, type: .run, startDate: Date(), duration: 3600, distance: 10000)
stravaClient.submitActivity(activity) { result in
switch result {
case .success(let activity):
// Activity submitted successfully, use the `activity`
case .failure(let error):
// Failed to submit activity, handle the error
}
}
“`
More Examples
For more examples and detailed usage instructions, refer to the official GitHub repository of FRDStravaClient: [link-to-github-repository](link-to-github-repository)
Conclusion
FRDStravaClient is a powerful iOS client for the Strava API, providing easy integration and access to Strava data. With simple authentication and convenient methods for retrieving and submitting activities, this library enables iOS developers to build feature-rich fitness and social apps.