iOS SDK

The open-source Gravatar iOS SDK is a Swift library that allows you to integrate Gravatar features into your own iOS applications. This SDK provides methods for fetching Gravatar images, managing Gravatar profiles, and leveraging the rich feature set that Gravatar offers.

Features

  • Download a Gravatar image using an email address or a URL.
  • Fetch a Gravatar profile using an email address.
  • Display a profile or an avatar through ready-to-use UI components.
  • Upload an Avatar to a Gravatar account using a wordpress.com access token.
  • Avatar URL calculator based on email and several query options.
  • Built-in image cache (it’s also possible to inject your own caching mechanism).
  • UIImageView extension to directly set the downloaded image.

Installation

Create an API key

Follow the steps in the REST API documentation to create a Gravatar API key. You can use some features without an API Key, but you’ll receive limited information, and stricter rate limits may apply, so we highly encourage you to create one in the developers’ portal.

Swift Package Manager

Adding Gravatar SDK to an iOS project in Xcode:

  1. File > Add Package Dependency
  2. Search by https://github.com/Automattic/Gravatar-SDK-iOS.git
  3. Click on Add Package

For more info, check the Apple Docs.

Adding Gravatar to a SPM project:

  1. Add Gravatar-SDK-iOS as a dependency of your project. It’s recommended to use the latest tagged version.
  2. Add the Gravatar product as a dependency of your target.
let package = Package(
    name: "Package Name",
    dependencies: [
        // 1.
        .package(url: "https://github.com/Automattic/Gravatar-SDK-iOS.git", from: "x.y.z")
    ],
    targets: [
        .executableTarget(
            name: "Target Name",
            dependencies: [
                // 2.
                .product(name: "Gravatar", package: "Gravatar")
            ]
        )
    ]
)

CocoaPods

Add pod 'Gravatar' to your target in your PODFILE.

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'MyApp' do
    pod 'Gravatar'
end

Next steps

Our “Get Started” guide on GitHub outlines the key steps for integrating the SDK into your iOS app and using it. Check it out to learn how to retrieve profile information and display it using our UI components.

Please refer to our complete documentation page and our GitHub repository for more information on how to integrate this SDK in your app.

For more code examples, check out our demo app!

Please note that these documents reflect our most up-to-date developments, so they might not perfectly align with the exact version of our SDK you’re currently working with.



Last updated on: