I am attempting to implement a means to open specific pages of my app via iOS 14's widget, but so far my attempt just simply open the app without picking up the full deeplinking URL.
In my main app's SceneDelegate.swift
:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let item = URLContexts.first {
print(item.url)
}
}
In my widget's EntryView
:
struct EntryWidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
VStack(alignment: .leading, spacing: 4) {
Link(destination: URL(string: "entry://link1")!, label: {
Text("Link 1")
})
Link(destination: URL(string: "entry://link2")!, label: {
Text("Link 2")
})
}
}
}
The above implementation prints "entry://"
every single time when I launch my app via the widget. This is regardless whether I tap anywhere on the widget, or on the Text
labels, all opens my app and prints "entry://"
, with the subsequent information (ie link1, link2) missing.
I believe I have setup the info.plist
correctly in my main app:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>entry</string>
</array>
</dict>
</array>