How to open Safari directly from Widget in SwiftUI? - swiftui

I have a link written in SwiftUI inside Widget View like this:
Link("Visit Apple",
destination: URL(string: "https://www.apple.com")!)
.font(.caption)
.foregroundColor(.red)
But now, I need to open this in Safari. Is it possible without opening the host app?

No, WidgetKit widgets always open their app. There’s no way around it. The best you can do is have your widget open your app (passing the web url) and then your app opens the passes URL in Safari automatically.

Related

Airdrop custom document type to SwiftUI DocumentGroup app

I am trying to get a simple SwiftUI iOS custom document app work with Airdrop. The app successfully opens a document when opened from Files or a Mail attachment. However when sending a document of the custom type by Airdrop from my mac, when the app is selected from the Airdrop notification, the app launches but only displays the file browser and the file does not seem to be copied over. No DocumentGroup view is displayed.
If I select Files from the Airdrop menu I can save the file.
I tried this with Apples sample code for DocumentBased apps, and it exhibits exactly the same behavior on my iPhone (iOS 16.0.2). Either this is a bug, or there is some extra secret sauce needed to get a SwiftUI Document app to receive files by Airdrop.
My custom type conforms to public.content, which I understand is required for Airdrop support.
Has anyone managed to get Airdrop reception working with a SwiftUI document app ?
I faced the same issue.
What I found out so far:
1.
Documents which are received via Airdrop are placed in your "Inbox" folder. This directory is located here:
let docUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
You can add an UIApplicationDelegate and UISceneDelegate to your swiftui application. Here you get a trigger when new files are received via Airdrop.
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
This function is normally trigged when you open your app with a URL in your browser.
I'm waiting for a integrated solution in the DocumentGroup.
https://developer.apple.com/documentation/swiftui/documentgroup

Open remote page as modal view in bootstrap

I thought this is very simple think to do, but I can't found it on internet.
How could I open outside page ( like https://google.com/ ) as a modal view?
I don't want to:
Open page in new tab
Open page in new popup window like:
onClick="MyWindow=window.open('http://www.google.com','MyWindow',width=600,height=300)
Open my own pre-prepared page as described here
Is there a way to do this? It should be reight?
You can try to use iframe:
<iframe src="https://google.com"></iframe>

How to Disable `back` and `forward` button of the browser window

In my applicaiton, I requried couple of things to be added.
No forward/Back Browser button should work for reach a hash.
Instead of brower back forward, there should be a back and forward button has to added in the applicaiton itself.
how to achive this both?
I am looking for a component to use globally for both 2 requriements.
Thanks in advance.
Disabling the native back/forward buttons of the browser in Ember.js is quite unusual but could possibly be achieved by using the NoneLocation class. To enable that open the config/environment.js file of your app and change the locationType property to none.
If you want to display back/forward buttons in your app you can use the History API and specifically window.history.back() and window.history.forward()

Google Maps not displaying in Qt WebView, other sites work

I just picked up Qt and QML for the first time and the first thing I wanted to get working was just to open Google Maps in a WebView but it doesn’t work.
Here’s the QML:
import QtQuick 2.0
import QtWebKit 3.0
Rectangle {
width: 1024
height: 960
WebView {
width: 1024
height: 960
anchors.centerIn: parent
url: "http://maps.google.com"
}
}
The window opens but the contents of the WebView are completely blank. If I try other websites then the correct web page is displayed.
What’s wrong with this code? I am not behind any proxy or firewall. I suspect it is something to do with HTTPS given that some maps APIs use HTTPS but I don’t see why HTTP would work but not HTTPS.
I am using Qt 5.1 on Windows 7 64-bit.

How to create Flip Page View on android?

How can I create flip page view on android like iOS with .pdf file
You can try FlexPaper, it supports Android and iOS
http://flexpaper.devaldi.com/examples/usecases/Whitepapers/Whitepaper_html5_pdf_sample.jsp