Skip to content

WhisperApp/Whisper-iOS-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Whisper-iOS-SDK

[![CI Status](http://img.shields.io/travis/Yujin Ariza/Whisper-iOS-SDK.svg?style=flat)](https://travis-ci.org/Yujin Ariza/Whisper-iOS-SDK) Version License Platform

The Whisper-iOS-SDK will let your users create Whisper content from inside your app with just a few lines of code. Currently, we support creating a Whisper post from an Image, Data, file path, or URL, with a custom text overlay.

Note that images using the SDK must be at least 640 pixels wide and 920 pixels high.

Requirements

The SDK requires that the Whisper app is installed. If version 4.2 or higher of the Whisper app is not installed, users will be prompted to the App Store to download it. Our app only supports iOS 6.0 or higher.

Installation

Whisper-iOS-SDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Whisper-iOS-SDK"

Usage

Manually Creating a Whisper

Manually creating a Whisper is done in two steps:

First, call either one of the configure methods. This defines the source of the menu presentation, which can be either a UIView, or a UIBarButtonItem.

[[WHPWhisperAppClient sharedClient] prepareWithView:view inRect:view.bounds];

Next, call one of the create methods to create the Whisper from any one of four data sources: UIImage, NSData, NSString, or NSURL.

[[WHPWhisperAppClient sharedClient] createWhisperWithImage:image error:&error];

Using a Whisper Button

Alternatively, you can use the standard Whisper button, and add it to your view:

UIButton *whisperButton = [[WHPWhisperAppClient sharedClient] whisperButtonWithSize:kWHPWhisperAppClientButtonSize_Medium rounded:YES];
[self.view addSubView:whisperButton];

When pressed, the button will retrieve the image data by calling protocol methods in the delegate property of the WHPWhisperAppClient. You can provide these methods by setting the delegate property to one of your own classes:

[WHPWhisperAppClient sharedClient].delegate = self;

...

-(UIView *)whisperAppClientViewForMenuPresentation
{
    return _view;
}

-(UIImage *)whisperAppClientSourceImageForWhisper
{
    return _image;
}

Note that your delegate class must conform to the protocol WHPWhisperAppClientDelegate.

App Callbacks

Finally, add the following method to your app's AppDelegate.m in order to enable callbacks from the Whisper app:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if ([WHPWhisperAppClient handleOpenURL:url sourceApplication:sourceApplication])
        return YES;
    return NO;
}

This will enable you to receive notifications when your app returns from a Whisper post, via a delegate method:

-(void)whisperAppClientDidReturnWithResult:(WHPPostResult)result
{
    switch (result) {
        case kWHPPostResult_Success:
            NSLog(@"Whisper post succeeded!");
            break;
        case kWHPPostResult_Failed:
            NSLog(@"Whisper post failed!");
            break;
        case kWHPPostResult_Canceled:
            NSLog(@"Whisper was canceled");
            break;
        case kWHPPostResult_Invalid:
            NSLog(@"Invalid input!");
            break;

        default:
            break;
    }
}

There is an example project that demonstrates the functionality described above, and some additional properties. To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Yujin Ariza, yujin@whisper.sh

License

Whisper-iOS-SDK is available under the Apache license. See the LICENSE file for more info.