测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布上次发布 | 2017年5月 |
由 Vadim Degterev、Anton Tikhonov、Olya Lutsyk、Orta Therox、Vlad Zavalikhatko 维护。
依赖库 | |
AFNetworking | = 3.1.0 |
DFImageManager | = 0.8.0 |
MBProgressHUD | = 1.0.0 |
SDWebImage | = 3.8.2 |
Stickerpipe 是 iOS 的贴纸 SDK
在 Stickerpipe 上获取 API 密钥
将 Framework 文件夹的内容添加到您的项目中。您也可以从这里获取源代码以进行低级别自定义和 iOS 7 支持
使用以下方式导入框架
swift
@import Stickerpipe
objC
#import <Stickerpipe/Stickerpipe.h>
在 AppDelegate.m 中设置 API 密钥
[STKStickersManager initWithApiKey:@"API_KEY"];
您可以在 http://stickerpipe.com 上获取自己的 API 密钥以设置自定义包
需要用户 ID。在指定之后,我们的 SDK 可以提供针对特定用户的包定制。所有对显示包设置的改变都会为此唯一键存储。
在检索用户 ID 后,使用以下方式将其设置为 STKStickersManager
[STKStickersManager setUserKey:@"USER_ID"];
如果您没有存储此类唯一 ID 的逻辑,可以使用 UUID 并将其存储到钥匙串中,以在安装之间保存。
初始化 STKStickerController 并将 stickersView 添加为 UITextView/UITextField 的输入视图。存储 stickerController 实例由您决定
@property (strong, nonatomic) STKStickerController *stickerController;
self.stickerController.textInputView = self.inputTextView;
使用代理方法接收来自贴纸视图控制器的贴纸消息
- (void) stickerController:(STKStickerController *)stickerController
didSelectStickerWithMessage:(NSString *)message;
并使用 UIImageView 显示它
- (void)stk_setStickerWithMessage: (NSString*)stickerMessage
completion: (STKCompletionBlock)completion;
或仅使用 imageManager 属性获取图像以进行自定义处理
- (void)getImageForStickerMessage: (NSString*)stickerMessage
withProgress: (STKDownloadingProgressBlock)progressBlock
andCompletion: (STKCompletionBlock)completion;
从代理方法返回您的控制器以显示模态控制器
- (UIViewController*)stickerControllerViewControllerForPresentingModalView;
在 AppDelegate 中注册推送通知。
添加
[STKStickersManager sendDeviceToken:deviceToken failure:nil];
调用委托方法
- (void)application:(UIApplication )application didRegisterForRemoteNotificationsWithDeviceToken:(NSData )deviceToken
添加
STKStickerController *stickerController = ...
[STKStickersManager getUserInfo:userInfo stickerController:stickerController];
调用委托方法
- (void) application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo
要添加关于贴纸的建议,您应该在屏幕上适当的位置添加 UICollectionView,例如在 UITextView 上方。然后,将您的集合视图附加到 STKStickerController。
self.stickerController.suggestCollectionView = self.yourCollectionView;
使用 showSuggests 属性启用建议
self.stickerController.showSuggests = YES;
为了接收到关于发送的贴纸和消息数量的正确统计信息,您应该调用 textMessageSendStatistic 和 stickerMessageSendStatistic 这对方法。
用户发送每条文本消息后,调用 textMessageSendStatistic
- (void)yourTextMessageDidSend {
[self.stickerController textMessageSendStatistic];
}
在委托方法中,用户向 STKStickerController 发送每个贴纸后,调用 stickerMessageSendStatistic
- (void)stickerController:(STKStickerController *)stickerController didSelectStickerWithMessage:(NSString *)message {
[self.stickerController stickerMessageSendStatistic];
}
您可以更改默认占位符颜色和商店内容颜色
贴纸视图中的占位符
[self.stickerController setColorForStickersPlaceholder:[UIColor redColor]];
贴纸视图头部的占位符
[self.stickerController setColorForStickersHeaderPlaceholderColor:[UIColor blueColor]];
商店内容颜色
[STKStickersManager setShopContentColor:[UIColor greenColor]];
使用 Stickerpipe 将自定义贴纸添加到 iMessage - http://stickerpipe.com/add-stickers-to-imessage
Stickerpipe 在 Apache 2 许可证下可用。有关更多信息,请参阅 LICENSE 文件。