SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
For Developing URL Routing of SwiftUI App
freddi - LINE Fukuoka
at potatotips (27th April,2020)
Goal of This Presentation
- SwiftUI(SceneDelegate) URL Routing
- URL Routing
- iOS12
URL Routing
- URL
https://snews.app/alerm
snews://alerm
URL Routing
-
- SceneDelegate URL ( )
- Routing
-
Parse URL in AppDelegate (Old way)
- AppDelegate application(_:, open:, options:)
- URL
// application(_:, open:, options:) -> Bool
func application(_ app: UIApplication, open url: URL, ...) -> Bool {
// Write down URL Parsing Procedure ...
return true
}
Parse URL in SceneDelegate
// scene(_:, openURLContexts:)
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
// Write down URL Parsing Procedure ...
}
New
- SceneDelegate scene(_:, openURLContexts:)
- AppDelegate Deprecated
※ SceneDelegate
URL Routing
-
- SceneDelegate URL
- Routing
-
Route to Goal Screen from Current Screen
- UIApplication.keyWindow Deprecated
Route to Goal Screen from Current Screen
- SceneDelegate.window
import UIKit
import SwiftUI
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
…
New
Route to Goal Screen from Current Screen
- UIWindow SwiftUI View
- … ViewController ?
Route to Goal Screen from Current Screen
- UIWindow SwiftUI View
- … ViewController ?
SwiftUI .sheet ViewController present
Route to Goal Screen from Current Screen
- UIWindow SwiftUI View
- … ViewController ?
UIWindow
UIHostingController(VC)
SwiftUI .sheet ViewController presentSwiftUI
Route to Goal Screen from Current Screen
- UIWindow SwiftUI View
- … ViewController ?
UIWindow
SwiftUI .sheet ViewController present
.sheet
.presentUIHostingController(VC)
SwiftUI
UIHostingController(VC)
SwiftUI
Route to Goal Screen from Current Screen
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
let url = URLContexts.first?.url
let distinationView = parseURLToDistination(url: url)
var currentTopVC = window?.rootViewController
while true {
if let presentedVC = currentTopVC?.presentedViewController {
currentTopVC = presentedVC
} else {
break
}
}
currentTopVC?.present(UIHostingController(rootView: distinationView), …
}
Route to Goal Screen from Current Screen
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
let url = URLContexts.first?.url
let distinationView = parseURLToDistination(url: url)
var currentTopVC = window?.rootViewController
while true {
if let presentedVC = currentTopVC?.presentedViewController {
currentTopVC = presentedVC
} else {
break
}
}
currentTopVC?.present(UIHostingController(rootView: distinationView), …
}
url
url View
VC
UIHostingController View
VC
URL Routing
-
- SceneDelegate URL
- Routing
-
Other Tips
- Navigation Coordinator
- sheet NavigationLink tag
- Navigation View push
- pushViewController
- Navigation UINavigationController
- NavigatorInsertionView( )
NavigatorInsertionView
struct NavigatorInsertionView: View {
static var contentView: AnyView? = nil
var body: some View { NavigatorInsertionView.contentView ??
{ () -> AnyView in
assertionFailure("Could not get AnyView")
return AnyView(EmptyView())
}()
}
}
NavigatorInsertionView
struct NavigatorInsertionView: View
NavigationLink("", destination: NavigatiorInsertionView(),
tag: Coordinator.MovingState.on,
selection: movingState)
.frame(width: 0, height: 0, alignment: .bottom)
Conclusion of URL Routing of SwiftUI App
- iOS13
- Coodinator
- SceneDelegate scene(_ scene:, openURLContexts:)
- Navigation VC present
https://hakata-swift.connpass.com/event/168308/

Contenu connexe

Tendances

Tendances (20)

Desenvolvendo APIs em Go usando Middlewares
Desenvolvendo APIs em Go usando MiddlewaresDesenvolvendo APIs em Go usando Middlewares
Desenvolvendo APIs em Go usando Middlewares
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Functional php
Functional phpFunctional php
Functional php
 
PHP pod mikroskopom
PHP pod mikroskopomPHP pod mikroskopom
PHP pod mikroskopom
 
JavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring RooJavaOne2010 Groovy/Spring Roo
JavaOne2010 Groovy/Spring Roo
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
21.search in laravel
21.search in laravel21.search in laravel
21.search in laravel
 
Feeds drupal cafe
Feeds drupal cafeFeeds drupal cafe
Feeds drupal cafe
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
Hidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysHidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeys
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Make WordPress realtime.
Make WordPress realtime.Make WordPress realtime.
Make WordPress realtime.
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 

Similaire à For Developing URL Routing of SwiftUI App

Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Yuji Hato
 

Similaire à For Developing URL Routing of SwiftUI App (20)

Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern[22]Efficient and Testable MVVM pattern
[22]Efficient and Testable MVVM pattern
 
Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15
 
How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0How to Build SPA with Vue Router 2.0
How to Build SPA with Vue Router 2.0
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 
Exemplo de Fluxograma de Arquitetura aplicativo
Exemplo de Fluxograma de Arquitetura aplicativoExemplo de Fluxograma de Arquitetura aplicativo
Exemplo de Fluxograma de Arquitetura aplicativo
 
Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJS
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC Internals
 
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ - Adaptive UI  - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
 
Juzu framework
Juzu frameworkJuzu framework
Juzu framework
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
 
Introducing Vuex in your project
Introducing Vuex in your projectIntroducing Vuex in your project
Introducing Vuex in your project
 

Plus de 秋 勇紀 (7)

Tutorial for developing SILOptimizer Pass
Tutorial for developing SILOptimizer PassTutorial for developing SILOptimizer Pass
Tutorial for developing SILOptimizer Pass
 
A Deeper Deep Dive into Swift Literal
A Deeper Deep Dive into Swift LiteralA Deeper Deep Dive into Swift Literal
A Deeper Deep Dive into Swift Literal
 
What Swifty is, from Enum
What Swifty is, from EnumWhat Swifty is, from Enum
What Swifty is, from Enum
 
Deep Dive into Swift Literal
Deep Dive into Swift LiteralDeep Dive into Swift Literal
Deep Dive into Swift Literal
 
SILOptimizerのCode Reading入門
SILOptimizerのCode Reading入門SILOptimizerのCode Reading入門
SILOptimizerのCode Reading入門
 
自作コンパイラのお話
自作コンパイラのお話自作コンパイラのお話
自作コンパイラのお話
 
ディープラーニングでポプテピピック
ディープラーニングでポプテピピックディープラーニングでポプテピピック
ディープラーニングでポプテピピック
 

Dernier

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Dernier (20)

Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 

For Developing URL Routing of SwiftUI App

  • 1. For Developing URL Routing of SwiftUI App freddi - LINE Fukuoka at potatotips (27th April,2020)
  • 2. Goal of This Presentation - SwiftUI(SceneDelegate) URL Routing - URL Routing - iOS12
  • 4. URL Routing - - SceneDelegate URL ( ) - Routing -
  • 5. Parse URL in AppDelegate (Old way) - AppDelegate application(_:, open:, options:) - URL // application(_:, open:, options:) -> Bool func application(_ app: UIApplication, open url: URL, ...) -> Bool { // Write down URL Parsing Procedure ... return true }
  • 6. Parse URL in SceneDelegate // scene(_:, openURLContexts:) func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { // Write down URL Parsing Procedure ... } New - SceneDelegate scene(_:, openURLContexts:) - AppDelegate Deprecated ※ SceneDelegate
  • 8. Route to Goal Screen from Current Screen - UIApplication.keyWindow Deprecated
  • 9. Route to Goal Screen from Current Screen - SceneDelegate.window import UIKit import SwiftUI class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? … New
  • 10. Route to Goal Screen from Current Screen - UIWindow SwiftUI View - … ViewController ?
  • 11. Route to Goal Screen from Current Screen - UIWindow SwiftUI View - … ViewController ? SwiftUI .sheet ViewController present
  • 12. Route to Goal Screen from Current Screen - UIWindow SwiftUI View - … ViewController ? UIWindow UIHostingController(VC) SwiftUI .sheet ViewController presentSwiftUI
  • 13. Route to Goal Screen from Current Screen - UIWindow SwiftUI View - … ViewController ? UIWindow SwiftUI .sheet ViewController present .sheet .presentUIHostingController(VC) SwiftUI UIHostingController(VC) SwiftUI
  • 14. Route to Goal Screen from Current Screen func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { let url = URLContexts.first?.url let distinationView = parseURLToDistination(url: url) var currentTopVC = window?.rootViewController while true { if let presentedVC = currentTopVC?.presentedViewController { currentTopVC = presentedVC } else { break } } currentTopVC?.present(UIHostingController(rootView: distinationView), … }
  • 15. Route to Goal Screen from Current Screen func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { let url = URLContexts.first?.url let distinationView = parseURLToDistination(url: url) var currentTopVC = window?.rootViewController while true { if let presentedVC = currentTopVC?.presentedViewController { currentTopVC = presentedVC } else { break } } currentTopVC?.present(UIHostingController(rootView: distinationView), … } url url View VC UIHostingController View VC
  • 16. URL Routing - - SceneDelegate URL - Routing -
  • 17. Other Tips - Navigation Coordinator - sheet NavigationLink tag - Navigation View push - pushViewController - Navigation UINavigationController - NavigatorInsertionView( )
  • 18. NavigatorInsertionView struct NavigatorInsertionView: View { static var contentView: AnyView? = nil var body: some View { NavigatorInsertionView.contentView ?? { () -> AnyView in assertionFailure("Could not get AnyView") return AnyView(EmptyView()) }() } }
  • 19. NavigatorInsertionView struct NavigatorInsertionView: View NavigationLink("", destination: NavigatiorInsertionView(), tag: Coordinator.MovingState.on, selection: movingState) .frame(width: 0, height: 0, alignment: .bottom)
  • 20. Conclusion of URL Routing of SwiftUI App - iOS13 - Coodinator - SceneDelegate scene(_ scene:, openURLContexts:) - Navigation VC present
  • 21.