Deep linking is an operating system-supported functionality that launches an app with an additional set of information on what an app should do once it’s launched.
You.i Platform supports getting the incoming deep link to launch an app, and sending outgoing deep links to launch other apps.
CYIDeepLinkBridge
classTwo types of incoming deep link events can occur:
For more information on deep linking:
React Navigation, a library for screen navigation in React-Native, interfaces directly with the native Linking module, but expects an URL format in a specific format: screenname/additionalinfo
.
For more details, see React Navigation Deep Linking.
The following diagram explains you why URL transformation is required:
In order to support deep linking and screen navigation with the React Navigation library, some platforms require URL to be transformed before the React Navigation library can access it.
This can be done by calling LinkingManager.setUrlTransform(‘sometransform’);
, where URL transforms are composed of tags in the following format: {function:argument1:argument2:argument3:defaultvalue(optional)}
, and:
The following is a generic example code for incoming deep link:
import { Linking } from 'react-native';
export default class IncomingDeepLinkHandlingClass extends Component {
constructor(props) {
// Connect to the Linking url event to handle mid-execution deep links.
Linking.addEventListener('url', this.handleOpenURL);
this.asyncConstructor();
}
async asyncConstructor() {
url = await Linking.getInitialURL();
// Handle Initial URL
}
handleOpenURL = ({ url }) => {
// Handle mid-execution URL
}
}
The following is a generic example for outgoing deep link:
import { Linking } from 'react-native';
export default class IncomingDeepLinkHandlingClass extends Component {
async canOpenUrl(url) {
canOpen = await Linking.canOpenURL(url);
// Handle boolean result 'canOpen'
}
async openURL(url) {
try {
await Linking.openURL(url);
} catch (e) {
// Handle error
}
}
}
To pass Roku certification, the app must support deep linking, which is an OS supported functionality that launches an app with the additional information about what an app should do once it’s launched. For more details, see the Roku Deep Linking documentation.
Regardless of the platform specific APIs that launch an app, You.i Platform passes the information used to launch the app coded into a URL. In case of Android and Apple devices, a URL is the only information required to launch an app. On other platforms, the information can vary.