TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Yujin Ariza, Paul Fleiner, Chad DePue.
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.
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.
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];
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
.
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.
Yujin Ariza, [email protected]
Whisper-iOS-SDK is available under the Apache license. See the LICENSE file for more info.