Snapchat Creative Kit iOS (Swift) - Image, Video, Sticker Sharing

Step 1: Setup Snap Kit Developer Portal

Step 2: Setup Project

  • SCSDKClientId (string): Client ID(OAuth2 Client ID)
  • LSApplicationQueriesSchemes (string-array): snapchat

Step 3: Install CreativeKit SDK

  1. Open your Podfile and add
pod 'SnapSDK', :subspecs => ['SCSDKCreativeKit']

Step 4: Preparing Media to Share Snapchat

  • Images must be JPEG or PNG
  • Videos must be MP4 or MOV
  • Shared media must be 300 MB or smaller
  • Videos must be 60 seconds or shorter
  • All resource URLs should be local
  • Videos that are longer than 10 seconds are split up into multiple Snaps of 10 seconds or less
  1. Import SDK:
import SCSDKCreativeKit
override func viewDidLoad() {super.viewDidLoad()snapAPI = SCSDKSnapAPI()}
let snapImage = /* Set your image here */let photo = SCSDKSnapPhoto(image: snapImage)let content = SCSDKPhotoSnapContent(snapPhoto: photo)
let photo = SCSDKSnapPhoto(imageUrl: snapImageUrl)
let videoUrl = /* prepare a local video URL */let video = SCSDKSnapVideo(videoUrl: videoUrl)let content = SCSDKVideoSnapContent(snapVideo: video)
  • Only one sticker is allowed
  • A still sticker must be a PNG or JPEG
  • An animated sticker must be a WebP (preferred) or GIF
  • Captions are limited to 250 characters
  • The attachment URL must be a properly formatted URL in string format
  • Universal links are not supported
let stickerImage = /* Prepare a sticker image */let sticker = SCSDKSnapSticker(stickerImage: stickerImage)/* Alternatively, use a URL instead */// let sticker = SCSDKSnapSticker(stickerUrl: stickerImageUrl, isAnimated: false)/* Modeling a content using SCSDKPhotoSnapContent */let content = SCSDKPhotoSnapContent(snapPhoto: photo)content.sticker = sticker /* Optional */content.caption = "Hello Guys!" /* Optional */content.attachmentUrl = "https://matrixsolution.xyz/" /* Optional */
/* Modeling a content using SCSDKVideoSnapContent */let content = SCSDKVideoSnapContent(snapVideo: video)

By default, the sticker appears in the center of the screen. You can set a default position and size to suggest specific placement, but users can resize and move the sticker around.

let stickerImage = /* Prepare a sticker image */let sticker = SCSDKSnapSticker(stickerImage: stickerImage)/* Alternatively, use a URL instead */// let sticker = SCSDKSnapSticker(stickerUrl: stickerImageUrl, isAnimated: false)/* Modeling a content using SCSDKNoSnapContent */let content = SCSDKNoSnapContent()content.sticker = sticker /* Optional */content.caption = "Hello Guys!" /* Optional */content.attachmentUrl = "https://matrixsolution.xyz/" /* Optional */
snapAPI?.startSending(content) { [weak self] (error: Error?) in// Handle response}

Conclusion

Source Code

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mohammad Mahmudul Hasan

Mohammad Mahmudul Hasan

37 Followers

A learner, constantly striving to learn new technologies and look the ways to be better in this rapidly changing industry.