iOS Content Sharing

To take advantage of this new feature in Flurry analytics, you’ll need to download the latest Flurry SDK for iOS. The feature is enabled starting wiht the iOS SDK version 7.0. Once you download the new SDK, make sure that you replace any existing Flurry library folders from your project’s file folder with the latest files before proceeding.

Follow the steps described in this guide.

The sample app that implements Tumblr in-app sharing, is avalable from the gitHub.

Log in to the Flurry Dashboard and Enable Content Sharing

To post content to Tumblr, you’ll need to enable your app for Content Sharing.

  1. Navigate to YourApplication > Manage
  2. Select App Info.
  3. In the Application Info panel, click Enable content sharing.

content sharing with tumblr

Set the Consumer API Key and Secret

Now you need to set your app’s consumer key and secret before you make any calls to FlurryTumblr using the following class method:

+ (void) setConsumerKey:(NSString*) consumerKey consumerSecret:(NSString*) consumerSecret;

Important

You’ll need to generate Tumblr oAuth keys, do so by clicking on the link Create Tumblr oAuth Key as caputred on the attached image. You’ll need these keys for users to be able to authenticate your app to post to Tumblr.


content sharing with tumblr

Fetch the Tumblr Image

If you want to use your own Tumblr image, you can do so.

Otherwise, use the following class method to fetch a UIImage and incorporate it into your view:

+ (UIImage*) tumblrImage;

Create and Send Your Post

Add FlurryTumblr.h to the implementation file that will post to Tumblr and share to Tumblr by using the following class method:

+ (void) post: (id<IFlurryTumblrShareParameters>)parameters  presentingViewController:(UIViewController*) presentingController;

Flurry will perform a one-time authentication of the user and then post the shared content to Tumblr.

To receive success and failure notifications, you’ll need to implement the FlurryTumblrDelegate protocol and register your viewController as the delegate with Flurry.

Text Share Parameters

Text Description
text The text content to share.
title The title of the text content.
iOSDeepLink [optional - highly recommended] Your app’s iOS deep link to the text content.
androidDeepLink [optional - highly recommended] Your app’s Android deep link to the text content.
webLink [optional - highly recommended] Your app’s Web link to the text content.

A Text Post Example

This example illustrates a text post with a title and body.

content sharing with tumblr

Image Share Parameters

Image Description
imageURL The imageURL to share. This can be http or a file URL. We recommend using high-quality image for better rendering and improved user experience.
imageCaption Caption for the image that needs to be shared.
iOSDeepLink [optional - highly recommended] Your app’s iOS deep link to the image content.
androidDeepLink [optional - highly recommended] Your app’s Android deep link to the image content.
webLink [optional - highly recommended] Your app’s Web link to the image content.

An Image Post Example

This example illustrates an image post with a caption.

content sharing with tumblr

Implement Flurry Tumblr Delegates (Optional)

If you want to be notified of success and failure during the authentication and posting to Tumblr, the calling object needs to implement FlurryTumblrDelegate protocol and the calling object needs to set itself as the delegate to FlurryTumblr.

+ (void) flurryTumblrPostSuccess;

+ (void) flurryTumblrPostError:(NSError*) error errorType:(FlurryTumblrErrorType) errorType;

Objective-C

#import "FlurryTumblr.h"
#import "FlurryTumblrDelegate.h"

-(void) viewDidLoad {
   // Get the Tumblr Image and incorporate it into your app’s view
   UIImage* tumblrImage = [FlurryTumblr tumblrImage];

   // set the consumer key and secret
   [FlurryTumblr setConsumerKey:@”Your Consumer Key” consumerSecret:@”Your Consumer Secret”];

   // set this view controller as the delegate to FlurryTumblr
   [FlurryTumblr setDelegate: self];
}

- (void) dealloc {
   // Note: please don’t set delegate to nil on viewDidUnload
   // as Flurry Tumblr views are shown modally
   [FlurryTumblr setDelegate: nil];
   [super dealloc];
}

- (void)tumblrPostImage:(NSURL*)imgPath withCaption:(NSString*)imgCaption
{
    FlurryImageShareParameters* imgShareParameters =
                                 [[FlurryImageShareParameters alloc] init];

    imgShareParameters.imageURL = [imgPath absoluteString];
    imgShareParameters.imageCaption = imgCaption;
    imgShareParameters.iOSDeepLink = @"Your App’s iOS Deep Link to Content";
    imgShareParameters.androidDeepLink = @"Your App’s Android Deep Link";
    imgShareParameters.webLink = @"Your App’s Web Link";

    [FlurryTumblr post:imgShareParameters presentingViewController:self];
}

- (void)tumblrPostText:(NSString*)title withBody:(NSString*)body
{
    FlurryTextShareParameters* textShareParameters =
                               [[FlurryTextShareParameters alloc] init];
    textShareParameters.text = body;
    textShareParameters.title = title;
    textShareParameters.iOSDeepLink = @"Your App’s iOS Deep Link to Content;
    textShareParameters.androidDeepLink = @"Your App’s Android Deep Link";
    textShareParameters.webLink = @"Your App’s Web Deep Link";

    [FlurryTumblr post:textShareParameters presentingViewController:self];
}

Swift

   override func viewDidLoad() {
    super.viewDidLoad()
    // Get Tumblr Image and incorporate it into your view
    var image = FlurryTumblr.tumblrImage();

    // Set your app’s consumer key and secret
    FlurryTumblr.setConsumerKey("Your Consumer Key", consumerSecret: "Your Consumer Secret")

    // Set this view controller as the delegate to FlurryTumblr
    FlurryTumblr.setDelegate(self)
 }

 func tumblrPostText(title: String, withBody body: String)
 {
    var textShareParameters = FlurryTextShareParameters();

    textShareParameters.text = body;
    textShareParameters.title = title;
    textShareParameters.iOSDeepLink = "Your App’s iOS Deep Link to Content";
    textShareParameters.androidDeepLink = "Your App’s Android Deep Link";
    textShareParameters.webLink = "Your App’s Web Deep Link";

    FlurryTumblr.post(textShareParameters, presentingViewController: self);
 }

 func tumblrPostImage(imageURL: NSURL, withCation caption: String)
 {
   var imgShareParameters = FlurryImageShareParameters();

   imgShareParameters.imageURL = imageURL.absoluteString;
   imgShareParameters.imageCaption = caption;
   imgShareParameters.iOSDeepLink = "Your App’s iOS Deep Link to Content";
   imgShareParameters.androidDeepLink = "Your App’s Android Deep Link";
   imgShareParameters.webLink = "Your App’s Web Deep Link";

   FlurryTumblr.post(imgShareParameters, presentingViewController: self);
}

Note that the image URL can be a http(s) or a local file path URL.