Receiving the Dynalink in Your App
When a Dynalink is opened, your app can capture the URL and react to it. Here’s how to handle incoming links on different platforms.
iOS (SwiftUI)
In SwiftUI apps, use the onOpenURL
modifier to capture and handle incoming URLs.
Example:
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
// Handle the incoming Dynalink
print("Received URL: \(url)")
// You can navigate or parse the URL here
}
}
}
}
This method is called automatically when the user opens your app via dynalink. More info on how to set up deep links can be found in the Apple documentation.
Android (Kotlin / Java)
On Android, you can retrieve the incoming URL through the Intent
that launched the activity.
Example (Kotlin):
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
val action: String? = intent?.action
val data: Uri? = intent?.data
}
The intent.data
holds the URI that triggered the app open. Make sure your activity is properly declared to handle deep links. More info on how to set up deep links can be found in the Android documentation.
React Native
For full documentation and best practices, visit the React Native Linking documentation.
Flutter
For full documentation and best practices, visit the app_links package documentation.