iOS SDK for access the OpenCage Geocoding API

Overview

OpenCageSDK

Requirements

OpenCageSDK works on iOS 9+ and requires ARC to build. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation.framework

You will need the latest developer tools in order to build OpenCageSDK. Old Xcode versions might work, but compatibility will not be explicitly maintained.

You will also need an API key from OpenCage to initialise this SDK. The API key is retrieved from here: https://opencagedata.com

Adding OpenCageSDK to your project

CocoaPods

CocoaPods is the recommended way to add OpenCageSDK to your project.

  1. Add a pod entry for OpenCageSDK to your Podfile pod 'OpenCageSDK'
  2. Install the pod(s) by running pod install
  3. Include OpenCageSDK wherever you need it with @import OpenCageSDK

Source files

Alternatively you can directly add the source files to your project, they are found under OpenCageSDK/Classes.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop the classes onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.

Static library

You can also add OpenCageSDK as a static library to your project or workspace.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop OpenCageSDK.xcodeproj onto your project or workspace (use the "Product Navigator view").
  3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add OpenCageSDK. You might also need to add OpenCageSDK to the Target Dependencies list.
  4. In Objective-C you may need to include OpenCageSDK with #import [yourprojectname]-swift.h.

Usage

OpenCageSDK is built on top of NSURLSession with a completionBlock so the network requests happen on a background thread, for setting up the SDK there is a convenience initialiser.

let ocSDK :OCSDK = OCSDK(apiKey: "YOUR-API-KEY")
OCSDK *sdk = [[OCSDK alloc] initWithApiKey:@"YOUR-API-KEY"];

Reverse Geocoding is done through the method below, any errors with the request are on the completionBlock 'error'. The response from the server is parsed into objects for ease of access.

let ocSDK :OCSDK = OCSDK(apiKey: "YOUR-API-KEY")
ocSDK.reverseGeocode(latitude: NSNumber(value: 51.5159), longitude: NSNumber(value: 0.1297), withAnnotations: true) { (response, success, error) in
    if success {
		//Successful payload response
    }
}
OCSDK *sdk = [[OCSDK alloc] initWithApiKey:@"YOUR-API-KEY"];
[sdk reverseGeocodeWithLatitude:@(51.5159) longitude:@(0.1297) withAnnotations:YES completionBlock:^(OCGeoResponse * _Nonnull response, BOOL success, NSError * _Nullable error) {
    if (success) {
        // Successful payload response
    }
}];

Forward Geocoding is done through the method below, any errors with the request are on the completionBlock 'error'. The response from the server is parsed into objects for ease of access.

let ocSDK :OCSDK = OCSDK(apiKey: "YOUR-API-KEY")
ocSDK.forwardGeocode(address: "3 Walls Court, Tewkesbury, England", withAnnotations: true) { (response, success, error) in
	if success {
		//Successful payload response
	}
}
OCSDK *sdk = [[OCSDK alloc] initWithApiKey:@"YOUR-API-KEY"];
[sdk forwardGeocodeWithAddress:@"3 Walls Court, Tewkesbury, England" withAnnotations:YES completionBlock:^(OCGeoResponse * _Nonnull response, BOOL success, NSError * _Nullable error) {
    if (success) {
        // Successful payload response
    }
}];

Documentation is provided in the OCSDK.swift file as well.

License

This code is distributed under the terms and conditions of the MIT license.

You might also like...
Muxer used on top of Feed iOS SDK for airplay

FeedAirplayMuxer Muxer used on top of Feed iOS SDK for airplay purposes. Demo Project -- https://github.com/feedfm/AirplayDemo Feed Airplay Muxer is

Basispay IOS SDK Version 2

BasisPay-IOS-KIT BasisPay IOS Payment Gateway kit for developers INTRODUCTION This document describes the steps for integrating Basispay online paymen

Release repo for Gini Bank SDK for iOS
Release repo for Gini Bank SDK for iOS

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Da Xue Zhang Platform Lvb iOS SDK

Cloud_Lvb_SDK iOS API Reference Dxz Meeting iOS SDK是为 iOS 平台用户音视频服务的开源 SDK。通过大学长开放平台自研RTC,RTM系统,为客户提供质量可靠的音视频服务。 类 类名 描述 CLS_PlatformManager SDK的音视频主要

PayPal iOS SDK

PayPal iOS SDK Welcome to PayPal's iOS SDK. This library will help you accept card, PayPal, Venmo, and alternative payment methods in your iOS app. Su

Spotify SDK for iOS
Spotify SDK for iOS

Spotify iOS SDK Overview The Spotify iOS framework allows your application to interact with the Spotify app running in the background on a user's devi

Headless iOS/Mac SDK for saving stuff to Pocket.
Headless iOS/Mac SDK for saving stuff to Pocket.

This SDK is deprecated Howdy all! 👋 Thanks for checking out this repo. Your 👀 mean a lot to us. 💗 Unfortunately, this project is deprecated, and th

Evernote Cloud SDK for iOS
Evernote Cloud SDK for iOS

Evernote Cloud SDK 3.0 for iOS This is the official Evernote SDK for iOS. To get started, follow the instructions bellow. Additional information can b

OneDrive SDK for iOS

Get started with the OneDrive SDK for iOS Integrate the OneDrive API into your iOS app! 1. Installation Install via Cocoapods Install Cocoapods - Foll

Owner
OpenCage GmbH
easy, affordable, worldwide geocoding API and geosearch made with open data
OpenCage GmbH
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
Unofficial Notion API SDK for iOS & macOS

NotionSwift Unofficial Notion SDK for iOS & macOS. This is still work in progress version, the module interface might change. API Documentation This l

Wojciech Chojnacki 59 Jan 8, 2023
150,000+ stickers API & SDK for iOS Apps.

English | 한국어 Stipop UI SDK for iOS Stipop SDK provides over 150,000 .png and .gif stickers that can be easily integrated into mobile app chats, comme

Stipop, Inc. 19 Dec 20, 2022
iOS SDK for the Box Content API

Box iOS SDK Getting Started Docs: https://developer.box.com/guides/mobile/ios/quick-start/ NOTE: The Box iOS SDK in Objective-C (prior to v3.0.0) has

Box 112 Dec 19, 2022
RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API.

RadioTimeKit - The Swift SDK for TuneIn RadioTimeKit is a Swift package to use the TuneIn API. The goal for development was to have a Swift SDK to get

Frank Gregor 2 Jun 20, 2022
Swift SDK for Blockfrost.io API

Swift5 API client for Blockfrost Swift 5 SDK for Blockfrost.io API. Installation • Usage • API Endpoints Installation Swift package manager dependenci

blockfrost.io 10 Dec 24, 2022
MpesaSDK - Swift SDK for the M-Pesa API (Mozambique)

M-Pesa SDK Swift package for M-Pesa API (Mozambique) Ready Methods/APIs C2B B2B

Algy Ali 16 Jul 29, 2022
Business-API - Business App an Application that show list business using the Yelp API

business-API Business App an Application that show list business using the Yelp

Edwin Niwarlangga 0 Jan 21, 2022
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

Radar COVID 146 Nov 24, 2022
TelegramStickersImport — Telegram stickers importing SDK for iOS

TelegramStickersImport — Telegram stickers importing SDK for iOS TelegramStickersImport helps your users import third-party programaticaly created sti

null 35 Oct 26, 2022