• Stars
    star
    432
  • Rank 100,650 (Top 2 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

Backboard

A motion-driven animation framework for Android.
Java
1,694
star
2

Graywater

An Android library for decomposing RecyclerView layouts to improve scroll performance.
Java
1,209
star
3

colossus

I/O and Microservice library for Scala
Scala
1,144
star
4

jetpants

MySQL toolkit for managing billions of rows and hundreds of database machines
Ruby
1,136
star
5

pytumblr

A Python Tumblr API v2 Client
Python
723
star
6

tumblr.js

JavaScript client for the Tumblr API
JavaScript
645
star
7

collins

groovy kind of love
Scala
572
star
8

Bookends

A UI widget for adding headers and footers to RecyclerView
Java
539
star
9

Remember

A preferences-backed key-value store
Java
523
star
10

policy

Tumblr policies and guidelines
453
star
11

laphs

Apple Live Photo support on the web, courtesy of Tumblr
JavaScript
447
star
12

tumblr.php

Tumblr API v2 PHP Client
PHP
407
star
13

k8s-sidecar-injector

Kubernetes sidecar injection service
Go
343
star
14

kanvas-ios

Kanvas: a creation tool for iOS
Swift
315
star
15

jumblr

Tumblr API v2 Java Client
Java
277
star
16

gocircuit

Go
237
star
17

genesis

A tool for data center automation
Ruby
156
star
18

docker-registry-pruner

Tool to apply retention logic to docker images in a Docker Registry
Go
127
star
19

data-lasso

JavaScript
119
star
20

docs

Tumblr's public platform documentation.
107
star
21

XExtensionItem

Easier sharing of structured data between iOS applications and share extensions
Objective-C
88
star
22

PermissMe

Java
75
star
23

webpack-web-app-manifest-plugin

A webpack plugin that generates a PWA manifest and integrates with the assets JSON.
JavaScript
75
star
24

k8s-secret-projector

Kubernetes Secret generation from secure credential repos
Go
72
star
25

k8s-config-projector

Create Kubernetes ConfigMaps from configuration files
Go
65
star
26

tumblrclient.go

This is a concrete implementation of the ClientInterface with additional convenience methods defined right on the client object
Go
42
star
27

go-collins

Collins API Client in Go - https://tumblr.github.io/collins
Go
41
star
28

tumblr.go

This is a library which provides structs and functions for accessing the Tumblr API
Go
37
star
29

JXHTTP

you know, for networking
Objective-C
25
star
30

Spectacles

A tiny library for parsing JSON podspecs.
Objective-C
23
star
31

gulp-css-hashes

JavaScript
18
star
32

tsd_proxy

Clojure
15
star
33

tumblr-repl

REPL for the Tumblr API, built on tumblr.js
JavaScript
12
star
34

collins_shell

Ruby
3
star
35

consolr

Ruby
1
star
36

chorus-timekeeper

DI with timekeeping.
PHP
1
star
37

collins_notify

Ruby
1
star
38

collins_client

Ruby
1
star
39

collins_auth

Ruby
1
star
40

slackr_archiver

Ruby
1
star