Skip to content

Commit

Permalink
Adds support for iOS deeplink inside demos-appyx-navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePT28 committed Nov 1, 2023
1 parent 4b9404e commit a7b08db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
15 changes: 14 additions & 1 deletion demos/appyx-navigation/ios/src/iosMain/kotlin/main.ios.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.bumble.appyx.navigation.navigator.Navigator
import com.bumble.appyx.navigation.node.root.RootNode
import com.bumble.appyx.navigation.ui.AppyxSampleAppTheme
import kotlinx.coroutines.flow.flowOf

import platform.Foundation.NSURL

private val integrationPoint = MainIntegrationPoint()
private val navigator = Navigator()
Expand Down Expand Up @@ -50,3 +50,16 @@ fun MainViewController() = ComposeUIViewController {
}.also { uiViewController ->
integrationPoint.setViewController(uiViewController)
}

@Suppress("FunctionNaming")
fun handleDeepLinks(url: NSURL) {
if (url.scheme == "appyx") {
when (url.host) {
// xcrun simctl openurl booted 'appyx://randomcake'
("randomcake") -> navigator.goToARandomCakeWithDummyUser()

// xcrun simctl openurl booted 'appyx://randomcake-wait'
("randomcake-wait") -> navigator.goToARandomCake()
}
}
}

Check warning

Code scanning / detekt

Checks whether files end with a line separator. Warning

The file /home/runner/work/appyx/appyx/demos/appyx-navigation/ios/src/iosMain/kotlin/main.ios.kt is not ending with a new line.
13 changes: 13 additions & 0 deletions demos/appyx-navigation/iosApp/iosApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>com.bumble.appyx.Appyx</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appyx</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
4 changes: 4 additions & 0 deletions demos/appyx-navigation/iosApp/iosApp/iOSApp.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import ios

@main
struct iOSApp: App {
Expand All @@ -7,6 +8,9 @@ struct iOSApp: App {
ZStack {
Color.white.ignoresSafeArea(.all) // status bar color
ContentView()
}
.onOpenURL { incomingURL in
Main_iosKt.handleDeepLinks(url: incomingURL)
}
}
}
Expand Down

0 comments on commit a7b08db

Please sign in to comment.