This Swift wrapper covers all possible network endpoints and responses for the Untappd API.
For a demonstration of the capabilities of CDUntappdKit; run the iOS Example project after cloning the repo.
- Authentication
- API Endpoints
- Activity Feed
- User Activity Feed
- The Pub (Local)
- Venue Activity Feed
- Beer Activity Feed
- Brewery Activity Feed
- Notifications
- User Info
- User Wish List
- User Friends
- User Badges
- User Beers
- Brewery Info
- Beer Info
- Venue Info
- Beer Search
- Brewery Search
- Checkin
- Toast/Un-toast
- Pending Friends
- Add Friend
- Remove Friend
- Accept Friend
- Reject Friend
- Add Comment
- Remove Comment
- Add to Wish List
- Remove from Wish List
- Foursquare Lookup
- Brand Assets
- Colors
- Logo
- Platform Support
- iOS
- macOS
- tvOS
- watchOS
- Documentation
- iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
- Swift 5.3+
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CDUntappdKit into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'CDUntappdKit', '1.1.0'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CDUntappdKit into your Xcode project using Carthage, specify it in your Cartfile
:
github "chrisdhaan/CDUntappdKit" == 1.1.0
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding CDUntappdKit as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/chrisdhaan/CDUntappdKit.git", .upToNextMajor(from: "1.1.0"))
]
If you prefer not to use any of the aforementioned dependency managers, you can integrate CDUntappdKit into your project manually.
- Open up Terminal,
cd
into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init
- Add CDUntappdKit as a git submodule by running the following command:
git submodule add https://github.com/chrisdhaan/CDUntappdKit.git
-
Open the new
CDUntappdKit
folder, and drag theCDUntappdKit.xcodeproj
into the Project Navigator of your application's Xcode project.It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
-
Select the
CDUntappdKit.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target. -
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
-
In the tab bar at the top of that window, open the "General" panel.
-
Click on the
+
button under the "Embedded Binaries" section. -
You will see two different
CDUntappdKit.xcodeproj
folders each with two different versions of theCDUntappdKit.framework
nested inside aProducts
folder.It does not matter which
Products
folder you choose from, but it does matter whether you choose the top or bottomCDUntappdKit.framework
. -
Select the top
CDUntappdKit.framework
for iOS and the bottom one for macOS.You can verify which one you selected by inspecting the build log for your project. The build target for
CDUntappdKit
will be listed as eitherCDUntappdKit iOS
,CDUntappdKit macOS
,CDUntappdKit tvOS
orCDUntappdKit watchOS
. -
And that's it!
The
CDUntappdKit.framework
is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Before contributing to CDUntappdKit, please read the instructions detailed in our contribution guide.
let untappdAPIClient = CDUntappdAPIClient(clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
redirectUrl: "YOUR_REDIRECT_URL")
Once you've created a CDUntappdAPIClient object you can use it to query the Untappd API using any of the following methods.
- Parameters with
// Optional
can take nil as a value. - Parameters with
// Required
will throw an exception when passing nil as a value.
public func fetchUserInfo(forUsername username: String?, // Optional
compact: Bool, // Required
completion: @escaping (CDUntappdUserInfoResponse?) -> Void)
The following lines of code show an example query to the user info endpoint.
// Cancel any API requests previously made
untappdAPIClient.cancelAllPendingAPIRequests()
// Query Untappd API for user info results
untappdAPIClient.fetchUserInfo(forUsername: "DehaanSolo",
compact: false) { (response) in
if let response = response,
let user = response.user {
print(user)
}
}
public func fetchUserWishList(forUsername username: String?,
offset: Int?,
limit: Int?,
sort: CDUntappdUserWishListSortType?,
completion: @escaping (CDUntappdUserWishListResponse?) -> Void)
The user wish list endpoint has a sort
parameter which allows for query results to be filtered based off six types of criteria. The following lines of code show which sort types can be passed into the sort
parameter.
CDUntappdUserWishListSortType.checkin
CDUntappdUserWishListSortType.date
CDUntappdUserWishListSortType.highestABV
CDUntappdUserWishListSortType.highestRated
CDUntappdUserWishListSortType.lowestABV
CDUntappdUserWishListSortType.lowestRated
The following lines of code show an example query to the user wish list endpoint.
untappdAPIClient.fetchUserWishList(forUsername: "DehaanSolo",
offset: 0,
limit: 10,
sort: .highestABV) { (response) in
if let response = response,
let wishList = response.wishList {
print(wishList)
}
}
public func fetchUserFriends(forUsername username: String?,
offset: Int?,
limit: Int?,
completion: @escaping (CDUntappdUserFriendsResponse?) -> Void)
The following lines of code show an example query to the user friends endpoint.
untappdAPIClient.fetchUserFriends(forUsername: "DehaanSolo",
offset: 0,
limit: 10) { (response) in
if let response = response,
let friends = response.friends {
print(friends)
}
}
The Untappd brand guidelines exist to achieve consistency and make sure the branded elements of Untappd are used correctly across every application.
class func untappdBrown() -> UIColor
class func untappdYellow() -> UIColor
The following lines of code show an example of how to use the brand color.
cell.textLabel?.textColor = UIColor.untappdBrown()
cell.textLabel?.textColor = UIColor.untappdYellow()
Christopher de Haan, [email protected]
Visit the Untappd Developers portal for additional resources regarding the Untappd API.
CDUntappdKit is available under the MIT license. See the LICENSE file for more info.