/stkiOS

iOS SDK for stickers from Stickerpipe

Primary LanguageObjective-COtherNOASSERTION

About

Version Platform License

Stickerpipe is a stickers SDK for iOS

ios

Installation

Get the API key on the Stickerpipe

Using CocoaPods (iOS 7 and later)

use_frameworks!
pod "StickerPipe"

or manualy (iOS 7 and later)

Add content of Framework folder to your project. You can also get sources from here for low-level customization and iOS 7 support

Usage

Import framework with:

swift:

@import Stickerpipe

objC:

#import <Stickerpipe/Stickerpipe.h>

Initializing

Set API key in your AppDelegate.m

[STKStickersManager initWithApiKey:@"API_KEY"];

You can get your own API Key on http://stickerpipe.com to have customized packs set.

Users

User id is required. After it specified, our SDK can provide user-specific packs customization. All changes to displayed packs settings are stored for thus unique keys.

After retrieving user id, set it to STKStickersManager with:

[STKStickersManager setUserKey:@"USER_ID"];

If you don't have logic for storing such unique id's, you can use UUID and store it to keychain, for saving between installations.

Presenting

Init STKStickerController and add stickersView as inputView for your UITextView/UITextField. Storing stickerController instance is up to you

@property (strong, nonatomic) STKStickerController *stickerController;

self.stickerController.textInputView = self.inputTextView;

Stickers

Use delegate method for recieving sticker messages from sticker view controller

- (void)  stickerController:(STKStickerController *)stickerController 
didSelectStickerWithMessage:(NSString *)message;

and display it with UIImageView:

- (void)stk_setStickerWithMessage: (NSString*)stickerMessage
					   completion: (STKCompletionBlock)completion;

or just retrieve an image for custom processing with imageManager property:

- (void)getImageForStickerMessage: (NSString*)stickerMessage 
                     withProgress: (STKDownloadingProgressBlock)progressBlock 
                    andCompletion: (STKCompletionBlock)completion;

Modals

Return your controller from delegate method for presenting modal controllers:

- (UIViewController*)stickerControllerViewControllerForPresentingModalView;

Push notifications

Register to push notifications in AppDelegate.

Add

[STKStickersManager sendDeviceToken:deviceToken failure:nil];

method call to delegate method:

- (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken  

Add

STKStickerController *stickerController = ...
[STKStickersManager getUserInfo:userInfo stickerController:stickerController];

method call to delegate method:

- (void) application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo

Suggests

To add suggestions about stickers you should add UICollectionView to appropriate place on you screen, for example above UITextView. Then attach your collection view to STKStickerController

self.stickerController.suggestCollectionView = self.yourCollectionView;

Enable your suggests with showSuggests property

self.stickerController.showSuggests = YES;

Statistics

To receive correct statistic about number of sent stickers and messages you should call pair of methods textMessageSendStatistic and stickerMessageSendStatistic.

Call textMessageSendStatistic after user send each text message

- (void)yourTextMessageDidSend {
    [self.stickerController textMessageSendStatistic];
}

Call stickerMessageSendStatistic after user send each sticker in delegate method to STKStickerController

- (void)stickerController:(STKStickerController *)stickerController didSelectStickerWithMessage:(NSString *)message {
    [self.stickerController stickerMessageSendStatistic];
}

Сustomizations

You can change default placeholders color and shop content color:

Placeholder in stickers view

[self.stickerController setColorForStickersPlaceholder:[UIColor redColor]];

Placeholder in stickers view header

[self.stickerController setColorForStickersHeaderPlaceholderColor:[UIColor blueColor]];

Shop content color

[STKStickersManager setShopContentColor:[UIColor greenColor]];

Credits

Add custom Stickers to iMessage with Stickerpipe - http://stickerpipe.com/add-stickers-to-imessage

Contact

i@stickerpipe.com

License

Stickerpipe is available under the Apache 2 license. See the LICENSE file for more information.