Pass a caption to instagram on Image sharing [Feature request]
See original GitHub issueHi,
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):
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:
- Created 5 years ago
- Reactions:2
- Comments:5
Top GitHub Comments
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 :
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…
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