Migrate from custom schemes (iOS)
Migrate from custom schemes (iOS)
If your application currently uses custom URL schemes such as myapp://product?id=123, Trustly recommends migrating to Universal Links. Custom schemes are less secure and provide a poorer user experience when compared to Universal Links.
To avoid customer disruptions, implement Universal Links as the primary deep linking method while keeping the custom scheme active as a fallback for older app versions or specific internal routing cases.
Required changes
The migration process involves shifting your infrastructure from a local, app-specific protocol to a verified, web-based standard.
The following table summarizes the key changes required to move from custom URL schemes to Universal Links.
Code migration strategy
When migrating, the most efficient approach is to create a unified route handler. This allows your app to accept links from both sources (Universal Links and custom URL schemes) and funnel them into a single logic flow. This ensures that users land on the same screen regardless of which link type they click.
Implement the Universal Link handler
Implement the scene(_:continue:) method in your SceneDelegate to intercept the modern HTTPS links. Instead of handling the navigation logic directly, the URL is extracted and passed to a shared helper function. For example:
Update the custom URL Scheme handler
Update your existing scene(_:openURLContexts:) method to pass the legacy URL to the shared helper function instead of duplicating your routing logic. For example:
Create the unified router
Create the handleDeepLink(url:) function to parse the following URL types:
- Universal Links: The route is usually defined in the path. For example,
https://site.com/product. - Custom schemes: The route is often defined in the host. For example,
myapp://product.
The following example demonstrates how to normalize these differences and execute the navigation: