Hide controls in sfsafariviewcontroller - ios

let sfViewController = SFSafariViewController(url: url)
sfViewController.delegate = self
self.ViewC!.present(sfViewController, animated: false, completion: nil)
I am opening a SFSafariViewController in my app. But for the security issue I do not want the controls given by this view. This view is giving Actions like- Done, Refresh, Share, Open in Safari.
For My purpose I just want Action- Done. Rest other actions should not be visible to user. I am supporting ios 10.0 + .
Atleast that toolbar should not be there.
Is it possible to do this?

No, You Can't customize SFSafariViewController .
Apple says:
Important
In accordance with App Store Review Guidelines, this view controller
must be used to visibly present information to users; the controller
may not be hidden or obscured by other views or layers. Additionally,
an app may not use SFSafariViewController to track users without their
knowledge and consent.
Lastly, indeed, you may use WKWebView instead for further customisation of your screen.
If your app lets users view websites from anywhere on the Internet,
use the SFSafariViewController class. If your app customizes,
interacts with, or controls the display of web content, use the
WKWebView class.
Read doc: https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller

Related

iOS Embed Activity (share) View Inline

The iOS UIActivityViewController overlays existing content as a stack. It is customisable but is there a way to move its position entirely and embed it inside another view.
Say I have a list of the user's contacts whom use my app. When clicking on one of those contacts, instead of overlaying the ActivityView, the contact would expand (accordion) and reveal certain elements of the ActivityView to allow user sharing.
I appreciate that this can be done by writing a custom Activity View however, unless I'm mistaken, there is no way to ascertain whether the user has certain other apps installed to allow sharing via WhatsApp or Messenger for example.

Is it possible customize SFSafariViewController like edit "Share" button?

Is it possible customize SFSafariViewController like:
- change "Share" button
- or add new button on same toolbar where "Share" and "Compass" buttons are
Any help will be appreciated.
No. However, you can change some specific configuration of that controller. Namely:
through SFSafariViewControllerConfiguration, you have barCollapsingEnabled and entersReaderIfAvailable.
Data for activityItemsForURL and excludedActivityTypesForURL.
preferredBarTintColor and dismissButtonStyle, etc...
Apple says:
Important
In accordance with App Store Review Guidelines, this view controller
must be used to visibly present information to users; the controller
may not be hidden or obscured by other views or layers. Additionally,
an app may not use SFSafariViewController to track users without their
knowledge and consent.
Lastly, indeed, you may use WKWebView instead for further customisation of your screen.
If your app lets users view websites from anywhere on the Internet,
use the SFSafariViewController class. If your app customizes,
interacts with, or controls the display of web content, use the
WKWebView class.
Read doc: https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller

Hide share options in Safari View Controller

Is there any way to hide the share option in Safari View Controller, which is coming by default?. I am trying to hide the extra options which are given by default with the Safari View Controller but not able to do so.
Let me know if anybody knows about this.
Thanks!
SFSafariViewController is not meant for customizations. Even Apple documentation says to use WKWebView if you want to customise the look and feel of safari view controller.
From Apple documentation
Choosing the Best Web Viewing Class
If your app lets users view websites from anywhere on the Internet,
use the SFSafariViewController class. If your app customizes,
interacts with, or controls the display of web content, use the
WKWebView class. When you adopt SFSafariViewController and a user
presses a link to peek at and then pop to the link’s destination, the
user views web content from within your app. Tapping Done, the user
returns to the view controller that was displayed before the web
content was loaded. When you instead use the WKWebView class, Peek and
Pop sends the user to Safari by default.
On the other hand, SFSafariViewController does provide some kind of UI customization. You can only change the preferredBarTintColor and prefererredControlTintColor. iOS 11 has new option to set initial configuration by using #NSCopying var configuration: SFSafariViewController.Configuration { get } but sadly that will not help you either

Scroll Down SFSafarViewController

I highly doubt it, but is there any way to scroll to a specific location in an SFSafariViewController? In a regular WKWebView, doing so is easy. All you need to call is [self.webView.scrollView setContentOffset:CGPointMake(0, 100)];. I've also considered trying to get the SFSafariViewController to evaluate Javascript and do it that way like WKWebViews can. If this is not possible please let me know.
According to the documentation, this is not the use case for SFSafariViewController.
The user's activity and interaction with SFSafariViewController are not visible to your app, which cannot access AutoFill data, browsing history, or website data
If you need to interact with the web view, use a web view(UIWebView or WKWebView). SFSafariViewController is meant to provide browser features within an app. You do not have control over what is going on within the view.

UIActivityViewController vs UIDocumentInteractionController in ios

I just read some articles on UIActivityViewController and UIDocumentInteractionController in iOS, but I am very confused about how to use them because both seem the same.
So, when do I use UIActivityViewController or UIDocumentInteractionController?
Is there any difference for Open In... & use UIActivityViewController?
I am very confused about how to use them. Please clarify to me their specific use.
In short, UIDocumentInteractionController deals with files while UIActivityViewController deals with various other services in your app. I'm not one to criticize much but you really should at least try to google and read at least the overview in the iOS Developer Docs.
UIDocumentInteractionController documentation:
A view controller that previews, opens, or prints files whose file format cannot be handled directly by your app.
...
Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file. For example, an email program might use this class to allow the user to preview attachments and open them in other apps.
After presenting its user interface, a document interaction controller handles all interactions needed to support file preview and menu display.
You can also use the delegate to participate in interactions occurring within the presented interface. For example, the delegate is notified when a file is about to be handed off to another application for opening. For a complete description of the methods you can implement in your delegate, see UIDocumentInteractionControllerDelegate.
UIActivityViewController documentation:
A view controller that you use to offer standard services from your app.
...
The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or SMS, and more. Apps can also define custom services.
Your app is responsible for configuring, presenting, and dismissing this view controller. Configuration for the view controller involves specifying the data objects on which the view controller should act. (You can also specify the list of custom services your app supports.) When presenting the view controller, you must do so using the appropriate means for the current device. On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.
Basically UIActivityViewController shares Data Objects (like Strings or Images) where UIDocumentInteractionController shares whole Documents / Files f.e. a PDF.

Resources