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.
You can find a detailed tutorial here. However, a simple setup is mentioned below.
Please ensure that you’ve created a
LSApplicationQueriesSchemesentry in your project’s Info.plist file and added an
instagram-storiesentry. 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.
let igData = IGData(backgroundType: .gradient, colorTop: .systemOrange, colorBottom: .systemRed, backgroundImage: nil, contentSticker: nil)
Next, create an instance of
IGDispatcher and initialize it with the
igData created above.
let igDispatcher = IGDispatcher(igData: igData)
Instagram suggests particular sizes for images shared to Instagram stories on their developer site.
|Asset||Preferred Size||For BackgroundType|
|Background Image||720x1080 (9:16 or 9:18)||
IGData is a Swift object that defines the data being shared to Instagram stories. It contains the following parameters:
backgroundType: Defines the
BackgroundType of the story.
BackgroundType is discussed in detail below.
colorTop: Defines the top color of the story background. In case of
.color background type, the
colorTop color is used as a solid color background.
colorBottom: Defines the bottom color of the story background. Used only in the case of
.gradient background type. In conjunction with the
colorTop property, Instagram renders a linear gradient as the story background.
backgroundImage: Defines the background image of the story background. Used only in the case of
.image background type.
contentSticker: Defines a content sticker image property. This sticker can be customized by the user in the Instagram app.
BackgroundType 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: A solid color background. User provides a
UIColor value and the
IGDispatcher 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 image
IGDispatcher will only create a story with a solid color background.
gradient: A linear gradient background. User provides two
colorBottom while configuring an
IGDispatcher 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 image
IGDispatcher will only create a story with a linear gradient background.
image: An image background. User provides an
UIImage into the
backgroundImage parameter while creating an object of type
IGDispatcher 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 image
IGDispatcher 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:
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
|Last commit: 3 weeks ago|