IOS 8.1 Swift UIActivityViewController does not show share in social networks (Facebook, twitter, WhatsApp, etc.)

I am trying to link sharing functions in my quick application, but I have a problem. I use UIActivityViewController to share image and text, but only the following options are available:

Share options

I need options for Facebook, Twitter and Whatsapp (and the rest!), But I can’t understand what I'm doing wrong.

I also tried other projects with a code / source, but I have the same problem, however, if I go on safari on the device, it offers the missing parameters of social networks on a common sheet.

Here is my code:

func shareTextImageAndURL(#sharingText: String?, sharingImage: UIImage?, sharingURL: NSURL?) { var sharingItems = [AnyObject]() if let text = sharingText { sharingItems.append(text) } if let image = sharingImage { sharingItems.append(image) } if let url = sharingURL { sharingItems.append(url) } let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil) activityViewController.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList] if(activityViewController.popoverPresentationController != nil) { activityViewController.popoverPresentationController?.sourceView = self.view; var frame = UIScreen.mainScreen().bounds // frame.height = frame.height / 2 var newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.width, height: frame.height / 2) activityViewController.popoverPresentationController?.sourceRect = frame; } self.presentViewController(activityViewController, animated: true, completion: nil) } 

Method call with

 var image = UIImage(named: "icon_messages.png")? shareTextImageAndURL(sharingText: "Hello this is a test", sharingImage: image, sharingURL: NSURL(string: "http://www.example.com/")) 

My device is iPhone 4s with iOS 8.1.

Here is another code I tried (with the same effect :)

 http://stackoverflow.com/questions/28169192/ios-swift-uiactivityviewcontroller-completion-handler-returns-success-when-tweet 

And this sample project:

 ttp://www.dvdowns.com/uiactivityviewcontroller/ 

Does anyone know what could be happening here? Thanks in advance!

+5
source share
3 answers

In the dvdowns.com/uiactivityviewcontroller/ comments, you have an answer:

let secondActivityItem: NSURL = NSURL (file urlwithpath: ...

NSURL (fileURLWithPath: " http://www.website.com/ ")! (Poorly)

NSURL (line: " http://www.dvdowns.com/ ")! (Good)

Best wishes!!

+1
source

Twitter link disappears from Share menu in iOS 8.3

0
source

I have the same problem and the answer is:

You probably haven’t logged into Facebook or Twitter in your device’s settings. They will not appear here unless the user logs in. Get rid of Apple.

Thanks Marty. You can find the answer here.

0
source

Source: https://habr.com/ru/post/1216174/


All Articles