Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
Sharing a story to Instagram with a background image and a sticker - IOS Swift

I'm trying to share a story with a background image a a sticker image via URL Scheme on my ios app, i am using the attached code and it dose not work. When i'm trying to share just a background image or just a sticker it does work. But when im trying share both a background image and a sticker in top of it, it dose not work.

Any Ideas?

func shareToInstagram(deepLinkString : String){
        let url = URL(string: "instagram-stories://share")!
        if UIApplication.shared.canOpenURL(url){

            let backgroundData = UIImageJPEGRepresentation(UIImage(named: "shop_placeholder")!, 1.0)!
            let creditCardImage = UIImage(named: "share_instagram")!
            let stickerData = UIImagePNGRepresentation(creditCardImage)!
            let pasteBoardItems = [
                                    ["com.instagram.sharedSticker.backgroundImage" : backgroundData],
                                    ["com.instagram.sharedSticker.stickerImage" : stickerData],
                                  ]

            if #available(iOS 10.0, *) {

                UIPasteboard.general.setItems(pasteBoardItems, options: [.expirationDate: Date().addingTimeInterval(60 * 5)])
            } else {
                UIPasteboard.general.items = pasteBoardItems
            }
            UIApplication.shared.openURL(url)
        }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I copy pasted OP's code for use in my own app (only substituting different UIImages) and found only 1 issue, pasteboard items should be contained in a single array otherwise instagram will render only the first item (in this case the background layer). To fix this, replace the declaration of pasteboard items with the following code

let pasteBoardItems = [
                ["com.instagram.sharedSticker.backgroundImage" : backgroundData,
                "com.instagram.sharedSticker.stickerImage" : stickerData]
            ]

(basically just remove the close and open bracket separating the two items)

Also as a previous answer stated, make sure "instagram-stories" is included in LSApplicationQueriesSchemes in the info.plist file

I use this exact code in my app and it now works perfect

over 4 years ago · Santiago Trujillo Report

0

Everything is correct, my code is similar and it works for iOS 11+. I suggest you the following:

  1. check the image data you pass to pasteboard (jpg can't be converted with UIImagePNGRepresentation and vice versa)
  2. check the info.plist. You should enable "instagram-stories" scheme in it (LSApplicationQueriesSchemes key)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!