Creating A Share Button Using Flutter for iOS and Android? - facebook

I'm converting some older Swift apps with Flutter. How can I create a "share" button using flutter that at least gets Facebook and Twitter and make it cross platform for my iOS and Android versions. Here is the Swift code I use....
let activityViewController : UIActivityViewController = UIActivityViewController(
activityItems: [firstActivityItem, secondActivityItem, image], applicationActivities: nil)
// This lines is for the popover you need to show in iPad
activityViewController.popoverPresentationController?.sourceView = (self.shareBTN)
// This line remove the arrow of the popover to show in iPad
activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection()
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)
actInd.stopAnimating()
self.present(activityViewController, animated: true, completion: nil)

Check out the Flutter share plugin -- it might have what you need.

As of Oct 2018, the best way I found was from this SO post here How do I share an image on iOS and Android using Flutter? that requires you use the File Provider package and know a little about Android Studio customization. Look for the answer from Albert Lardizabal. Looks like he may be part of the team that made the awesome "Hamilton" Flutter app.

Related

Unable to open MS Word and PDF docs with SFSafariViewController in latest iOS 13.0

We are trying to use SFSafariViewController to browse a Word document from our iOS Mobile app using Swift as it gives ReaderView and Font Increase/Decrease within the App. Everything works as expected on the Simulator with 12.2 ios version, however when we published the changes to TestFlight and started using the app on a real phone ios 13.0 version the SFSafariViewController shows the FileName and says "Open in 'Dropbox' 'More... '"
https://i.stack.imgur.com/R595d.jpg
we want to disable/remove that option to choose different apps to open the word/pdf docs and display the content directly within the app. Would greatly appreciate if someone can help remove this option and directly display the documents like below.
https://i.stack.imgur.com/EhFec.png
Below is the code. Can someone please help how to resolve this issue?
func openGuidelineSafari(passedURL: String) {
let allowedCharacterSet = CharacterSet(charactersIn: " ").inverted
let escapedString = passedURL.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet)
let url = URL (string: (escapedString!))
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true
let vc = SFSafariViewController(url:url!, configuration: config)
vc.delegate = self
present(vc, animated: true)
}

Instagram embed not working on some mobile devices

It loads the placeholder "View this post on Instagram" instead embedded media. Standard Instagram embed code is used, and this happens both in Chrome and Firefox browsers on the same device. Interesting, it is happening on Android and iOS, but only on small number of devices I test.
Any idea?
I ran into the same issue using a WKWebView in iOS 12. The solution that worked for me was to use an iframe with the standard link with "/embed" as the last path element, rather than the embed code provided by Instagram. Example from a viewDidLoad():
let embed = "<iframe src=\"https://www.instagram.com/p/BwdGxDGAOcP/embed\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\"></iframe>"
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let webview = WKWebView(frame: view.frame, configuration: config)
webview.uiDelegate = self
view = webview
webview.loadHTMLString(embed, baseURL: nil)

How to save document to "Files" App in swift [duplicate]

This question already has answers here:
How to write a file to a folder located at Apple's Files App in Swift
(2 answers)
Closed 3 years ago.
I just created a PDF document in my app and I want to save the document on the device in a way that the "Files" app can access the saved document.
When you download a PDF document in Safari there is an option to save the document to the "Files" app, which is what I'm trying to do.
I Googled for several hours but wasn't able to find any useful methods.
If you have access to your PDFdata then you could present the user with a UIActivityViewController where they can then save it to Files, or share it with any of the other available options:
let activityViewController = UIActivityViewController(activityItems: ["Name To Present to User", pdfData], applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
Minimum of iOS 11
The Files app was introduced in iOS 11. You will not be presented with the option to save to Files when you are on a version less than iOS 11. With that being said, documents can be downloaded to a variety of different apps depending on the settings available on the user's phone and the options you allow.
#available(iOS 11.0, *)
func savePDF() {
guard let documentData = document.dataRepresentation() else { return }
let activityController = UIActivityViewController(activityItems: [documentData], applicationActivities: nil)
self.present(activityController, animated: true, completion: nil)
}
This is an example of a way to save a document. You can't force it to be downloaded and show up in their Files app. You have to present a UIActivityViewController that shows options on what they can do with that document.
If you want to exclude any options shown on the UIActivityViewController, then implement excludedActivityTypes like so.
activityController.excludedActivityTypes = [.airDrop, .postToTwitter]
Try UIDocumentInteractionController:
let doc = UIDocumentInteractionController(url: url)
doc.presentOptionsMenu(from:in:animated:)
There's an option named save to Files.

Is it possible to show the app UI portion of iOS sharing extension into a page control in SWIFT?

I am using the following code to share text using iOS sharing extension (UIActivityViewController).
let vc = UIActivityViewController(activityItems: ["File URL"], applicationActivities: [])
presentViewController(vc, animated: true, completion: nil)
It shows a popup to share using text sharing applications like following:
But, I want the sharing app portion in my view into a page control like below:
How can I do this? If there is any alternative way to achieve this requirement, kindly suggest.

Share image On facebook in watchKit using the Social sdk

i want share the image on Facebook in iWatch kit now problem occur in one line need help
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) { var twitterSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
twitterSheet.setInitialText("Share on Twitter")
self.presentViewController(twitterSheet, animated: true, completion: nil)
}
Now problem in last line code the error is this classname does not have a member name presentViewController
There's a few issues here:
WatchKit does not include the Social framework.
WKInterfaceController does not include the method presentViewController.
You may want to look into using Handoff to share the item from the user's phone, instead.