Overview
SnapchatKit is a powerful iOS framework that allows developers to easily integrate Snapchat functionalities into their applications. With SnapchatKit, you can create engaging features such as sharing content, sending snaps, accessing user data, and much more. This documentation will guide you through the installation process, provide an overview of available functionalities, and offer code examples to help you get started with integrating Snapchat into your iOS app.
Installation
To install SnapchatKit in your iOS project, you can use CocoaPods, a dependency manager for iOS projects.
1. Add the following line to your project’s Podfile:
pod 'SnapchatKit'
2. Run the following command from your project’s root directory:
pod install
Getting Started
In order to use Snapchat’s API, you need to obtain API credentials by creating an application in your Snap Kit developer portal.
1. Sign in to the Snap Kit developer portal (https://www.snapkit.com/).
2. Create a new application and enter the necessary details.
3. Once your application is created, you will receive Client ID and Client Secret. These credentials are required for authentication with the Snapchat API.
4. Include the required SnapchatKit libraries in your project:
#import <SnapchatKit/SnapchatKit.h>
5. Initialize SnapchatKit with your Client ID and Client Secret:
[[SCSDKSnapAPI sharedInstance] startWithClientId:@"YOUR_CLIENT_ID" clientSecret:@"YOUR_CLIENT_SECRET" redirectUri:@"YOUR_REDIRECT_URI"];
Functionalities
Here are some of the key functionalities offered by SnapchatKit:
- Authentication: Allow users to sign in with their Snapchat credentials.
- User Data: Access user data such as display name, Bitmoji, and friends.
- Bitmoji Kit: Integrate Bitmoji Stickers into your app.
- Story Kit: Allow users to share their stories from your app to their Snapchat account.
- Content Sharing: Share images, videos, and captions to Snapchat.
- Sending Snaps: Send snaps directly from your app.
Examples
Here are some code examples to help you get started:
Example 1: Authenticating a User
[[SCSDKLoginClient sharedInstance] loginFromViewController:self completion:^(BOOL success, NSError * error) { if (success) { // User is authenticated } else { // Authentication failed } }];
Example 2: Sharing Image to Snapchat
SCSDKSnapPhoto *photo = [[SCSDKSnapPhoto alloc] initWithImage:image]; SCSDKSnapContent *content = [[SCSDKSnapContent alloc] init]; content.snapPhoto = photo; [[SCSDKSnapAPI sharedInstance] startSendingContent:content completionHandler:^(NSError * error) { if (error) { // Sharing failed } else { // Sharing successful } }];
Feel free to explore more examples and functionalities in the official Snapchat Developer Documentation.