IGStoryKit
lets you easily share content stickers with different background types to Instagram stories from your iOS and iPadOS apps.
IGStoryKit
is available via Swift Package Manager. To add IGStoryKit
simply add this repo’s URL to your project’s package file.
https://github.com/SwapnanilDhol/IGStoryKit
A simple setup is mentioned below.
Please ensure that you’ve created a
LSApplicationQueriesSchemes
entry in your project’s Info.plist file and added aninstagram-stories
entry. Without this your project will not be able to copy data into Instagram stories and this framework will thrown an assertion failure during debug runtime.
import IGStoryKit
let story = IGStory(contentSticker: myImage, background: .color(.systemOrange))
Next, create an instance of IGDispatcher
and initialize it with the story
object created above.
let dispatcher = IGDispatcher(story: story)
dispatcher.start()
Instagram suggests particular sizes for images shared to Instagram stories on their developer site.
Asset | Preferred Size | For BackgroundType |
---|---|---|
Content Sticker | 640x480 | .none , .color , .gradient , .image |
Background Image | 720x1080 (9:16 or 9:18) | .image |
IGData
is a Swift object that defines the data being shared to Instagram stories. It contains the following parameters:
-
background
: Defines theBackground
of the story.Background
is discussed in detail below. -
contentSticker
: Defines a content sticker image property. This sticker can be customized by the user in the Instagram app.
Background
is an enum that describes the background type of the Instagram Story. It can be of 4 pre defined types:
-
.none
: No background. This mode requires that the user shares a sticker image content. -
.color(color: .systemOrange)
: A solid color background. User provides aUIColor
value as part of the associated valuesof this enum case and theIGDispatcher
class creates a Instagram story with a solid background color. For this case the user may or may not provide a sticker content image. In case the user doesn’t provide a sticker content imageIGDispatcher
will only create a story with a solid color background. -
.gradient(colorTop: .systemOrange, colorBottom: .systemRed)
: A linear gradient background. User provides twoUIColor
intocolorTop
andcolorBottom
as part of the associated values of this enum case. TheIGDispatcher
class then creates an Instagram story with a linear gradient background. For this case, the user may or may not provide a sticker content image. In case the user doesn’t provide a sticker content imageIGDispatcher
will only create a story with a linear gradient background. -
.image(image: backgroundImage)
: An image background. User provides anUIImage
as part of the associated value of this enum case. TheIGDispatcher
class then creates an Instagram story with an image background. For this case, the user may or may not provide a sticker content image. In case the user doesn’t provide a sticker content imageIGDispatcher
will only create a story with an image background.
If you like IGStoryKit
please consider buying me a coffee 🥰
Contributions are always welcome. Please follow the following convention if you’re contributing:
- NameOfFile: Changes Made
- One commit per feature
- For issue fixes: #IssueNumber NameOfFile: ChangesMade
This project is licensed under the MIT License - see the LICENSE file for details
If you’re using IGStoryKit in your app please open a PR to edit this Readme. I’ll be happy to include you in this list :D