Hi,
I'll try to implement new widgets in my project.
My app is based on objc and swift.
I want to use new "Link" of SwiftUI 2 to receive different URLs from the widget to the AppDelegate of my app.
According with the min 12:40 of this video, I want multiple links in medium and large size of my widget:
developer.apple.com/videos/play/wwdc2020/10028
Like the project "Emoji ranger" from session "Widgets Code-Along".
This is an example of my code:
Where "urlschemes" is the same of URL Schemes in URL types of my app target info.
So I want to receive the selected link on the App Delegate, where I used this method:
Thanks in advance
Fulvio
I'll try to implement new widgets in my project.
My app is based on objc and swift.
I want to use new "Link" of SwiftUI 2 to receive different URLs from the widget to the AppDelegate of my app.
According with the min 12:40 of this video, I want multiple links in medium and large size of my widget:
developer.apple.com/videos/play/wwdc2020/10028
Like the project "Emoji ranger" from session "Widgets Code-Along".
This is an example of my code:
Code Block HStack { Link(destination: URL(string: "urlschemes://link1")!, label: { Image("landscape") }) Link(destination: URL(string: "urlschemes://link2")!, label: { Image("portrait") }) }
Where "urlschemes" is the same of URL Schemes in URL types of my app target info.
So I want to receive the selected link on the App Delegate, where I used this method:
Code Block -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{ NSLog(@"RECEIVED URL: %@",url); }
Thanks in advance
Fulvio
Hi,
Thanks for your answer.
Yes the delegate method did not call in AppDelegate.
But I just solved the problem, I found out that I had made a mistake.
in my question I wrote this sample code for use link:
But in my project I use a custom view called "myPhotoSwiftUIView" so in the reality my code is :
Here is the mistake, inside my custom class I had added the property ".widgetURL", as soon as I removed it the "Link" works correctly, and the App delegate method application:openURL:options: start to work.
Thanks for your time I hope that my question could help some other developers
Thanks for your answer.
Yes the delegate method did not call in AppDelegate.
But I just solved the problem, I found out that I had made a mistake.
in my question I wrote this sample code for use link:
Code Block Link(destination: URL(string: "urlschemes://link1")!, label: { Image("landscape") })
But in my project I use a custom view called "myPhotoSwiftUIView" so in the reality my code is :
Code Block Link(destination: URL(string: "urlschemes://link1")!, label: { myPhotoSwiftUIView(imageName: "landscape") })
Here is the mistake, inside my custom class I had added the property ".widgetURL", as soon as I removed it the "Link" works correctly, and the App delegate method application:openURL:options: start to work.
Thanks for your time I hope that my question could help some other developers