question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass a caption to instagram on Image sharing [Feature request]

See original GitHub issue

Hi,

First, thanks for this cool package.

I was reading #310

And I’m facing the same issue with : "react-native": "0.58.5", "react-native-share": "^1.1.3",

But I believe there is even a better way than “degrade gracefully” to solve this.

While not achieving to share anything with react native (at the beginning), I went native like native native. (then i came back from my native dreams)

And in swift I succeed to pass a caption to instagram:

func postImageToInstagramWithCaption(imageInstagram: UIImage, instagramCaption: String, view: UIView) {
        // called to post image with caption to the instagram application
        
        let instagramURL = NSURL(string: kInstagramURL)
        
        if UIApplication.shared.canOpenURL(instagramURL! as URL) {
            
            let jpgPath = (NSTemporaryDirectory() as NSString).appendingPathComponent(kfileNameExtension)
            
            do {
                try imageInstagram.jpegData(compressionQuality: 1.0)?.write(to: URL(fileURLWithPath: jpgPath), options: .atomic)
                
            } catch {
                
                print(error)
            }
            
            let rect = CGRect(x: 0, y: 0, width: 612, height: 612)
            let fileURL = NSURL.fileURL(withPath: jpgPath)
            documentInteractionController.url = fileURL
            documentInteractionController.delegate = self
            documentInteractionController.uti = kUTI
            
            // adding caption for the image
            documentInteractionController.annotation = ["InstagramCaption": instagramCaption]
            documentInteractionController.presentOpenInMenu(from: rect, in: view, animated: true)
        } else {
            
            /// display some message about how it didn't work
            let r = UIAlertController(title: kAlertViewTitle, message: kAlertViewMessage, preferredStyle: .alert)
            
            print(r)
        }
    }

( Thanks to this SO, tested and worked in my swift code)

Can’t say how to achieve this in Kotlin/Java for android, but there is way to pass caption (according to the kotlin master in my team):

Useful infos here

So yeah that’s not Obj-C (as i can see that your native code is Obj-C) but you can as well link these functions too in some way. You might even know better than me how to do so :

Swift Mixed code source Obj-C / Swift

I’m really not a native mobile dev, so I cannot submit a pull request. But I can give you the fruits of my researches in the native world.

Note : This way of sharing to instagram also show facebook / twitter / snapchat / whatsapp … as an option to share, and you can add more field to add caption to facebook for example (without breaking instagram sharing)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

2reactions
lbnlrntcommented, Mar 13, 2019

Re-reading this, i think the all function is not even mandatory. I feel like it is “just” to add :

["InstagramCaption": instagramCaption]

To the dictionary in Obj-C because it seems that it is what Instagram is waiting for (looking for in the call) and it may be just a new key in the optional parameter as per “subject” to email in this options :

const options = {
  subject: "for email",
  instagramCaption: "for insta"
}
Share.open(options)

It would surely break the ability to add to instagram story. But at least you can choose if you want to have the caption or the instagram story share…

0reactions
github-actions[bot]commented, May 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a “discussion” and i will leave this open

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass a caption to instagram on Image sharing [Feature request]
Pass a caption to instagram on Image sharing [Feature request] #461 ... While not achieving to share anything with react native (at the ......
Read more >
Is it possible to send a caption/annotation to Instagram via its ...
This feature does exist, it just hasn't been added to the documentation yet. Starting with our next release (2.3.0) you'll be able to...
Read more >
264 Creative Instagram Captions for 2023 - Hootsuite Blog
If you want your entire caption to display “above the fold,” stick to 125 characters or fewer. After that, followers will have to...
Read more >
8 Ways to Share Links on Instagram - Social Media Examiner
You can't include clickable links in the captions of normal Instagram photo posts, but that doesn't mean that post captions are useless!
Read more >
How To Write Short Instagram Captions in 2023 [+Examples]
1. Instagram shortens your caption after three to four lines, so include important details in the beginning. Only about the first sentence will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found