Unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.

Overview

Tumblr SDK for iOS

An unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application. The library uses ARC requires at least iOS 9 or OS X 10.10.

If you have any feature requests, please let us know by creating an issue or submitting a pull request. Please use the Tumblr API responsibly and adhere to the Application Developer and API License Agreement.

Table of Contents

Getting started

CocoaPods

CocoaPods is the recommended way to add the Tumblr SDK to your project. Using CocoaPods means you don't need to worry about cloning or adding this repository as a git submodule. CocoaPods is a package manager like gem (Ruby) and npm (Node.js), but for Swift and Objective-C projects.

Module authors create "pods" which are versioned and stored in a central repository. App developers create "podfiles" to specify their apps' dependencies and use the CocoaPods command line tool to:

  • Fetch the dependencies specified in their podfile
  • Recursively fetch all subdependencies
  • Create an Xcode workspace that includes the pods, links any necessary libraries, configures header search paths, enables ARC where appropriate, and more

If you're new to CocoaPods, the website contains lots of helpful documentation.

To install the Tumblr SDK you can simply create a podfile in your application's root directory that looks as follows:

platform :ios, '9.0'

pod 'TMTumblrSDK'

After running pod install, you'll have an Xcode workspace that includes not only your application but also the Tumblr SDK. That's really all there is to it.

You will get the latest version of the SDK by referring to it simply by name (TMTumblrSDK). This guide explains how explicit dependency versions can instead be specified.

If you choose to include TMTumblrSDK manually (i.e. without CocoaPods) please make sure that your app can still read TMTumblrSDK.podspec.json. We use this for tracking which versions of TMTumblrSDK are in use, which helps us make informed decisions about the project’s future.

Documentation

Appledoc for the SDK can be found here. If you install the Tumblr SDK using CocoaPods, the docset is automatically added to Xcode for you.

Connecting to Tumblr

API client

Use the TMAPIClient class for communication with Tumblr via the Tumblr API. A typical use case for the API client is an application that allows a user to share a photo to multiple social networks at the same time. In this case, after allowing a user to select a photo, you might present them with a list of toggles representing the different networks that would receive the photo. Once they confirm, and assuming they selected Tumblr, you would use the API client to post the image to the user's Tumblr. Use of the API Client requires authentication from the user for certain routes which you may facilitate through the TMOAuthAuthenticator class.

Please view the API documentation for full usage instructions.

OAuth Authentication

In your AppDelegate, import <TMTumblrSDK/TMOAuthAuthenticator.h>, <TMTumblrSDK/TMURLSession.h>, and TMOAuthAuthenticatorDelegate.h.

Declare constants for your app’s Tumblr consumer key and secret:

NSString * const OAuthTokenConsumerKey = @"";
NSString * const ConsumerSecret = @"";

If you don't already have a consumer key/secret you can register here.

Setup

In your app’s Info.plist, specify a custom URL scheme that the browser can use to return to your application once the user has permitted or denied access to Tumblr:

        <key>CFBundleURLTypes</key>
        <array>
                <dict>
                        <key>CFBundleTypeRole</key>
                        <string>Editor</string>
                        <key>CFBundleURLName</key>
                        <string>com.tumblr.example</string>
                        <key>CFBundleURLSchemes</key>
                        <array>
                                <string>my-sample-app</string>
                        </array>
                </dict>
        </array>

In your app delegate setup your TMURLSession and TMOAuthAuthenticator instances, for example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.applicationCredentials = [[TMAPIApplicationCredentials alloc] initWithConsumerKey:OAuthTokenConsumerKey consumerSecret:ConsumerSecret];

    self.session = [[TMURLSession alloc] initWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
                                        applicationCredentials:self.applicationCredentials
                                               userCredentials:[TMAPIUserCredentials new]
                                        networkActivityManager:nil
                                     sessionTaskUpdateDelegate:nil
                                        sessionMetricsDelegate:nil
                                            requestTransformer:nil
                                             additionalHeaders:nil];

    self.authenticator = [[TMOAuthAuthenticator alloc] initWithSession:self.session
                                                applicationCredentials:self.applicationCredentials
                                                              delegate:self];

    ViewController *vc = [[ViewController alloc] initWithSession:self.session authenticator:self.authenticator];

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];

    return YES;
}

Also add the ability to handle incoming URL requests and also conform to TMOAuthAuthenticatorDelegate

On iOS this looks like:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    [self.authenticator handleOpenURL:url];
    return YES;
}

#pragma mark - TMOAuthAuthenticatorDelegate

- (void)openURLInBrowser:(NSURL *)url {
    [[UIApplication sharedApplication] openURL:url];
}

Then, use these instances in an authenticate method in another class such as a view controller, for example

- (void)authenticate {
    [self.authenticator authenticate:@"ello" callback:^(TMAPIUserCredentials *creds, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error) {
                self.authResultsTextView.text = [NSString stringWithFormat:@"Error: %@", error.localizedDescription];
            }
            else {
                self.session = [[TMURLSession alloc] initWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] applicationCredentials:[[TMAPIApplicationCredentials alloc] initWithConsumerKey:@"" consumerSecret:@""] userCredentials:[[TMAPIUserCredentials alloc] initWithToken:creds.token tokenSecret:creds.tokenSecret]];
                self.authResultsTextView.text = [NSString stringWithFormat:@"Success!\nToken: %@\nSecret: %@", creds.token, creds.tokenSecret];
                [self request];
            }
        });
    }];
}

Attribution and Deep Links

If your app posts to Tumblr, you can provide the API Client with deep link URLs under the keys TMPostKeyDeepLinkiOS and TMPostKeyDeepLinkAndroid. This will cause attribution UI for your app to be displayed beneath the post on the respective platform. When this UI is tapped, the OS will open the deep link you specified. Be aware that all icons and required fields must be provided in your app's configuration before this UI will be visible.

NOTE: This is currently only available to whitelisted app partners. Contact Tumblr business development ([email protected]) if your app requires this functionality.

Share extension

As of iOS 8, Tumblr for iOS ships with a share extension. It currently supports the following input types:

  • Text
  • Images (maximum: 10)
  • Video (maximum: 1)
  • URL (maximum: 1)

In the future, we hope to document specific ways for apps to pass parameters to be used for creating the different Tumblr post types, but we’d need to figure out a good way to do so that won’t interfere with other share extensions that could also potentially be displayed.

If you're looking to hardcode some Tumblr-specific behavior, our share extension’s bundle identifier is com.tumblr.tumblr.Share-With-Tumblr.

Deprecated Connection Methods

  • URL schemes [Deprecated]
  • UIActivityViewController [Deprecated]

Example

The repository includes iOS and macOS sample applications.

Contact

License

Copyright 2012-2017 Tumblr, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • Problem while trying to login with webview authenticate: webView: callback:

    Problem while trying to login with webview authenticate: webView: callback:

    Hi, can anyone please explain to me what is the problem ?I Do clean the cache but nothing ...

    Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x18807a90 {NSErrorFailingURLKey=http://www.tumblr.com/oauth/request_token?oauth_callback=tumblrauthbeapping%3A%2F%2Ftumblr-authorize, NSErrorFailingURLStringKey=http://www.tumblr.com/oauth/request_token?oauth_callback=tumblrauthbeapping%3A%2F%2Ftumblr-authorize, NSUnderlyingError=0x18807ae0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"}

    opened by soufianeEssabbane 38
  • UIDocumentInteractionController UTI

    UIDocumentInteractionController UTI

    Is there a specific UTI I can use for the Tumblr App, or do I always have to use public?

    Reason this is a concern. Everyone has the .png UTI in their apps now. So sending to tumblr is more like, sending to 20 different image processing apps, with tumblr buried in there.

    opened by frankynines 25
  • Not able to upload image after authentication

    Not able to upload image after authentication

    [TMAPIClient sharedInstance].OAuthConsumerKey = k_TUMBLR_CONSM_KEY;

    [TMAPIClient sharedInstance].OAuthConsumerSecret = k_TUMBLR_SECRET_KEY;

    [[TMAPIClient sharedInstance] authenticate:@"myapp://tumblr-authorize" callback:^(NSError *error) {

    if (error)
    
        NSLog(@"Authentication failed: %@ %@", error, [error description]);
    
    else{
    
        NSLog(@"Authentication successful!");
    
        [[TMAPIClient sharedInstance] photo:@"Test"
    
                              filePathArray:@[[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]]
    
                           contentTypeArray:@[@"image/png"]
    
                              fileNameArray:@[@"Default.png"]
    
                                 parameters:@{@"caption" : @"Caption"}
    
                                   callback:^(id response, NSError *error) {
    
                                       if (error)
    
                                           NSLog(@"Error posting to Tumblr");
    
                                       else
    
                                           NSLog(@"Posted to Tumblr");
    
                                   }];
    
    }
    

    }];

    I am trying to post image after authentication, i am able to authenticate using above code but not able to post image after success full authentication. I am getting @"Error posting to Tumblr". I did some debugging and getting request callback JSON below:

    (NSDictionary *) $1 = 0x0715df70 { meta = { msg = "Not Authorized"; status = 401; }; response = ( ); }

    Please guide me what i am missing ?

    opened by ashishguru1986 23
  • x-callback-rul /action/link?description param does not seem to support HTML

    x-callback-rul /action/link?description param does not seem to support HTML

    Example:

    tumblr://x-callback-url/link?title=Your%20old%20laptop%27s%20battery%20will%20light%20homes%20in%20developing%20countries&url=http%3A%2F%2Fwww.engadget.com%2F2014%2F12%2F09%2Fibm-urjar-battery%2F&description=%21%28http%3A%2F%2Fo.aolcdn.com%2Fhss%2Fstorage%2Fmidas%2F4bdd5bcbafad648d96057bd6ba4968aa%2F201215004%2Flight-bulb-street-vendor-india-daniel-berehulak-getty.jpg%29%0A%0A%3Cimg%20src%3D%27http%3A%2F%2Fo.aolcdn.com%2Fhss%2Fstorage%2Fmidas%2F4bdd5bcbafad648d96057bd6ba4968aa%2F201215004%2Flight-bulb-street-vendor-india-daniel-berehulak-getty.jpg%27%3E%0A%0A%3E%20Don%27t%20be%20too%20quick%20to%20toss%20out%20the%20battery%20from%20that%20ancient%20laptop%20--%20it%20might%20just%20be%20the%20key%20to%20powering%20homes%20in%20developing%20countries%2C%20and%20helping%20the%20environment%20in%20the%20process.%20IBM%20researchers%20have%20revealed%20UrJar%2C%20a%20device%20that%20turns%20old%20lithium-ion%20battery%20packs%20into%20rechargeable%20energy%20sources%20for%20low-power%20devices%20like%20LED%20light%20bulbs%2C%20fans%20and%20cellphones.%0A%0AWhat%20a%20great%20idea.%20Places%20that%20accept%20batteries%20for%20recycling%20or%20proper%20disposal%20need%20to%20get%20clued%20into%20this.%0A%0A%20
    

    The description field will be completely empty when Tumblr launches.

    opened by joshgoebel 10
  • xauth failed. Error code 400.

    xauth failed. Error code 400.

    When I xauth,I always get error(code 400) in callback block. Here is my code: [TMAPIClient sharedInstance].OAuthConsumerKey = @"KzKNocy4NqAYiIK.........."; [TMAPIClient sharedInstance].OAuthConsumerSecret = @"NDxQ3s1Nz9........"; [[TMAPIClient sharedInstance] xAuth:@"[email protected]" password:@"....." callback:^(NSError *error) { NSLog(@"%@", error); }]; I can't find where the problem is. Help!

    opened by mh4u 9
  • 404/Not Found in OAuth Flow

    404/Not Found in OAuth Flow

    Cool that you just dropped the tumblr sdk right now when I needed it! Thank's ;)

    Anyway, I get a 404 page during the OAuth Flow and I can't figure out why this happens..

    I added the sdk via CocoaPods.

    I am just using these lines like said in the readme:

    [TMAPIClient sharedInstance].OAuthConsumerKey = @"xxxxxxxxx";
    [TMAPIClient sharedInstance].OAuthConsumerSecret = @"xxxxxxxxxx";
    
    [[TMAPIClient sharedInstance] authenticate:@"boutiquiee_tumblr" callback:^(NSError *error) {
            // You are now authenticated (if !error)
            NSLog(@"error: %@", error);
        }];
    

    After Safari starts and I hit allow or deny it ends at the url

    http://www.tumblr.com/oauth/boutiquiee_tumblr/tumblr-authorize?oauth_token=xxxx&oauth_verifier=xxxx

    which gives a 404 Error page..

    Any idea what could be the issue?

    opened by krisdigital 7
  • No visible @interface for TMAPIClient declares the selector 'handleOpenURL:'

    No visible @interface for TMAPIClient declares the selector 'handleOpenURL:'

    I'm trying to follow the tutorial to use the SDK.

    I'm following the steps, installed the SDK via pods, imported the header <TMTumblrSDK/TMAPIClient.h>.

    When I try to insert the URL handling code:

    return [[TMAPIClient sharedInstance] handleOpenURL:url];

    I'm getting an error indicating the interface doesn't declare the method.

    What am I doing wrong?

    I'm on latest iOS SDK + Xcode 8.3.

    opened by canpoyrazoglu 6
  • Authentication via SFSafariViewController (iOS 9) and TMWebViewController (up to iOS 8)

    Authentication via SFSafariViewController (iOS 9) and TMWebViewController (up to iOS 8)

    Implemented method +- (void)authenticate:(NSString *)URLScheme fromViewController:(UIViewController *)fromViewController callback:(void(^)(NSError *))error; that allows to authenticate on iOS. For iOS up to 8 TMWebViewController is used (included in SDK, without XIB, code-only). From iOS 9, SFSafariViewController is used. Some minor refactoring included as well (TMSDKConstants.h contains a special error domain and error codes for the SDK).

    opened by shpuntov 6
  • Add support for Carthage

    Add support for Carthage

    In order to support Carthage in TMTumblrSDK, this library and all of its dependencies must have a shared framework scheme.

    • Add Carthage support to all dependencies.
    • Remove existing static lib target from project file.
    • Add a framework target and add all relevant source files.
    • Set the scheme for building this target to "shared".
    • Add all public headers to the framework's umbrella header.
    • Tag this commit as a new release, or Carthage will never look at it.
    opened by sozorogami 6
  • Add Proper Module Support

    Add Proper Module Support

    Although TMTumblrSDK compiles as a framework, it exposes the umbrella header for JXHTTP. This isn’t the right behavior, and it causes a few issues when attempting to debug Swift code.

    enhancement 
    opened by paulrehkugler 6
  • With oAuth 2.0 user is having to authenticate repeatedly

    With oAuth 2.0 user is having to authenticate repeatedly

    This may be due to a programming error on my part, but there is a problem with our App retaining the signin via oAuth 2.0.

    Each time the app starts it has to re-authent, i.e.: kicks out to the web browser and the auth page and then back to the app.

    Is there anything we have to do regarding timeouts, preserving the login state to stop this happening?

    opened by paulfreeman 6
  • not working in ios real device. in rare case its work but most of time fails to get auth details

    not working in ios real device. in rare case its work but most of time fails to get auth details

    i am getting error, The operation couldn't be completed. Software caused connection abort. it working in simulator and in device some times its work but its rare case its work else its return error.

    opened by jaydeep0004 2
  • Share Post on tumblr

    Share Post on tumblr

    Hello,

    I want to share Text, image and video on tumblr using my application. i used following code but it not upload it give success but post not display on my dashboard post. My code is in swift and using bridging for this.

    ` let request : TMRequestFactory = TMRequestFactory(baseURLDeterminer: TMBasicBaseURLDeterminer.init())

    let client : TMAPIClient = TMAPIClient(session: self.session!, requestFactory: request)

    let task : URLSessionTask = client.postDataTask(withBlogName: "sampleText", type: "text", parameters: ["body" : "this is my sample post please check it is post or not"]) { (data, response, error) in if (error != nil) { print(error!) } else { print(String(data: data!, encoding: String.Encoding.utf8) ?? "Error") } }

        task.resume()`
    
    opened by hirenspaceo 0
  • Not supporting iOS 9 anymore?

    Not supporting iOS 9 anymore?

    When CocoaPods is used, the latest version is not available for iOS 9. If the library really only supports iOS 10 and higher versions. Please modify the relevant documents.

    opened by developforapple 0
  • Tumblr API video post returns wrong post id

    Tumblr API video post returns wrong post id

    I am getting wrong post id response after posting video.

    This is the id I got -"id":169538154740

    When I call , Retrieve published posts for a blog through Tumblr API Console

    I am getting another post id - "id": 169538157127,

    opened by rathish24 1
  • Fetch posts by tag method no longer available

    Fetch posts by tag method no longer available

    It looks like the taggedRequest() method was removed in this commit. The previous functionality of this method is still the correct way to fetch posts by tag, as documented on https://api.tumblr.com.

    Currently, clients can still construct the GET /v2/tagged requests themselves via TMRequestFactory, but we should continue to provide a convenience method, as we do for other common actions.

    bug 
    opened by ceyko 1
Releases(5.3.2)
Federal Data SDK built in the Swift programming language. Follow the link for the documentation:

Swift-Federal-Data-SDK Federal Data SDK built in the Swift programming language Until the Swift language becomes more stable, consider this a beta rel

null 65 May 28, 2022
An Application to list the products and on selection of product list the detail of particular product

Merchandising An Application to list the products and on selection of product list the detail of particular product This application uses VIPER design

Poonam Yadav 0 Nov 28, 2021
QuizGame: an iOS application that offers quizes

Quiz Game QuizGame is an iOS application that offers quizes. ✨ Application Features It is a simple iOS app built by Swift, which presents a quick quiz

Alharbi 2 Dec 25, 2021
This repository is for the iOS sample application using ARGear SDK.

ARGear sample application for iOS (c) Copyright 2021 Seerslab. All rights reserved. This repository contains an iOS sample application that uses ARGea

ARGear 2 Apr 5, 2022
JustTrivia - Trivia Application Created in Swift

JustTrivia - Trivia Application Created in Swift Usage Please use a small number

null 0 Dec 30, 2021
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
Accept credit cards and PayPal in your iOS app

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themse

PayPal 973 Dec 18, 2022
All in one eKYC (Electronic Know Your Customer) solution available for android and ios

WideKYC All in one eKYC (Electronic Know Your Customer) solution available for android and ios. Wide Technologies provides an SDK for you to implement

Wide Technologies Indonesia 5 Nov 2, 2022
A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elastic Path Commerce Cloud written in Swift.

Elastic Path Commerce Cloud iOS Swift SDK A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elasti

Moltin 36 Aug 1, 2022
Used to integrate the Facebook Platform with your iOS & tvOS apps.

Facebook SDK for iOS This open-source library allows you to integrate Facebook into your iOS app. Learn more about the provided samples, documentation

Meta 7.3k Jan 3, 2023
Client library for accessing Azure Storage on an iOS device

Azure Storage Client Library for iOS Overview This library is designed to help you build iOS applications that use Microsoft Azure Storage. At the mom

Microsoft Azure 81 Oct 15, 2022
Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app.

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.

Shopify 411 Jan 2, 2023
Home-assistant-swift-sdk - Used to integrate the Home Assistant APIs with your Swift-based apps.

home-assistant-swift-sdk This open-source library allows you to interact with a Home Assistant instance in your Swift-based (e.g., iOS, macOS, etc.) a

Alexander Golden 0 Dec 31, 2021
Doll - A mac app to help monitor your app badges

Doll is a Mac app that help you catch up important messages! In macOS, It feels

null 328 Jan 4, 2023
Smooch is the best way to have personal, rich conversations with people on your website or customers on any device

Smooch is the best way to have personal, rich conversations with people on your website or customers on any device. Our features, integrations and developer-friendly APIs empower companies to connect with their customers in a whole new way.

Zendesk 121 Aug 1, 2022
iOS_UHF_Sample is a sample App to demonstrate how to use UHFSDK library.

iOS_UHF_Sample is a sample App to demonstrate how to use UHFSDK library.

GIGA-TMS 0 Dec 6, 2021
A library for creating Stream Deck plugins in Swift.

StreamDeck A library for creating Stream Deck plugins in Swift. Usage Your plugin class should inherit from StreamDeckPlugin, which handles the WebSoc

Emory Dunn 15 Jan 2, 2023
The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips.

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

Gini GmbH 0 Dec 16, 2021
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