I currently have an app in the store that I am updating. The app allows a user to click a button and then share the image using the iOS Sharing Extension. Is there a way to detect which option the user has selected (ex: Facebook or Twitter) and then resize the image according to the option selected? I know how to resize my image just have no clue where to begin with the conditional.
Currently this is what I have for my button:
if let image = sender.currentImage {
let objectsToShare = [image]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
//New Excluded Activities Code
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
//
self.presentViewController(activityVC, animated: true, completion: nil)
}
Related
I'm using UIActivityViewController to present the share sheet.
can share the image and text together as expected in all apps except in WhatsApp. There only the text is being shown to send and not the image.
What am I doing wrong here?
let text = "Hey! Check this out"
let shareSheet = UIActivityViewController(activityItems: [text, UIImage(named: "Light-HomeScreen")!], applicationActivities: nil)
self.present(shareSheet, animated: true, completion: nil)
Thanks in advance
I am trying to share UIImage with text to other applications.
All works good, but with what's app, i have some troubles.
What's app shares only text without image.
let activityViewController = UIActivityViewController(activityItems: [img, NSLocalizedString("text", comment: "")], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)
I'm developing an iOS application using swift and firebase.
I'm trying to add sharing ability, where the user can share some information from firebase to social networkings apps.
Here's the button I added:
#IBAction func text2share(sender: AnyObject) {
let text2share = "Check out this 😍✨ \r\n Business Name: \(self.BusinessNameL.text!) \r\n Phone: \(self.PhoneNumberTV.text!) \r\n Category: \(self.CategoryL.text!) \r\n Website: \(self.Website1TV.text!) \r\n in Business Wallet app 📲"
let objects2Share = [text2share]
let activityVC = UIActivityViewController(activityItems: objects2Share, applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
}
When I tried it, it worked for all social networks apps except for whatsapp and Facebook!
*Here's the error I got when I try to share it to whatsapp:
*Here's What I got when I share to Facebook:
And the link is empty!
Is there anybody know how can I solve this?
And why this happens?
It's a bug on whatsapp.
Check this
thread. It discusses the same. It seems like a very recent bug as earlier the same methods used to work. Check this answer by santhu for possible workaround or wait since they have admitted to resolve the bug.
if you try this code, you can share just the URL which I was talking about.
let textToShare = "Check out this Business Name"
let appURL = NSURL(string: "http://www.google.com")! as NSURL
let objectsToShare = [textToShare, appURL]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
//New Excluded Activities Code
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
if you want to share your text via facebook add excludeActivities
let activityVC = UIActivityViewController(activityItems: objects2Share, applicationActivities: nil)
let excludeActivities = [UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypeMessage, UIActivityTypeMail]
activityVC.excludedActivityTypes = excludeActivities
self.presentViewController(activityVC, animated: true, completion: nil)
In my app there is text displayed in a label on screen.
I have a share button when pressed brings the UIActivityViewController but when you press the share extensions ex: Twitter, you get the compose view with nothing inside of it.
I want it that it puts the text from the label on the screen into the compose view.
I don't know how you did this but it would work well.
suppose you put it on a action sheet :
let share = UIAlertAction(title: "Share my label!", style: .Default, handler: { action in
let shareMessage = myLabel.text
let itemsToShare = [shareMessage]
let activityViewController = UIActivityViewController(activityItems: itemsToShare,
applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
})
How would I create a button that allows the user to share their high score on social media? For example, flappy bird had a button that allowed that led the user straight to twitter saying "I just scored 15 on flappy bird! #FlappyBird" or whatever their high score is. I have created a label and have a block of code that runs when the user taps it, but I have no clue where to start with the rest.
In a SKScene:
let textToShare = "I just did \(labelScore) on the game! Try to beat me, it's free!"
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
let currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow!.rootViewController!
currentViewController.presentViewController(activityVC, animated: true, completion: nil)
You can use this code to open the share menu on iOS and let the user decide where to share.
let textToShare = "cool text"
let objectsToShare = [textToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
Here is an answer I've given for Twitter sharing in Sprite Kit. This is using objective-c. But I do agree with PJTrail that you should make an effort to learn how it is done instead of just copy/ pasting the code. That way you can edit it for your own needs in the future.
Link: Twitter share button in a sprite-kit game