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
IGStory
objectlet story = IGStory(contentSticker: myImage, background: .color(.systemOrange))
Next, create an instance of IGDispatcher
and initialize it with the story
object created above.
IGDispatcher
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 the Background
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 a UIColor
value as part of the associated valuesof this enum case 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(colorTop: .systemOrange, colorBottom: .systemRed)
: A linear gradient background. User provides two UIColor
into colorTop
and colorBottom
as part of the associated values of this enum case. The 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(image: backgroundImage)
: An image background. User provides an UIImage
as part of the associated value of this enum case. The 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
link |
Stars: 68 |
Last commit: 49 weeks ago |
Added a new source_application
property to the IGStory Dee-link as required by Meta now.
For more information visit: https://developers.facebook.com/blog/post/2022/10/10/introducing-important-update-to-Instagram-sharing-to-stories
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics