Add React Native Module
To display React Native content within your Choicely app, you need to add theChoicelyReactNative module.
- In Xcode, with your app project open, navigate to File > Add Packages.
-
Add the Choicely SDK repository if you haven’t already:
-
Select the
ChoicelyReactNativemodule in addition toChoicelyCore.
Enable URL Navigation from React Native
To allow React Native JavaScript code to open Choicely content usingLinking.openURL(), you need to register a custom URL scheme and forward URLs to the SDK.
1. Register URL Scheme
Add thechoicely URL scheme to your app’s Info.plist:
2. Handle URLs in AppDelegate
Forward incoming URLs to the SDK by implementing the URL handler in your AppDelegate:Using Linking.openURL in React Native
Once configured, your React Native JavaScript code can open any Choicely content using theLinking API:
Replace
your-article-key, your-contest-key, and your-feed-key with the actual content keys from Choicely Studio. You can find these keys in the content settings for each article, contest, or feed.Passing Parameters to React Native Modules
You can pass data to your React Native modules using query parameters. These parameters will be automatically converted to props and passed to your component.Query parameter values are always passed as strings. Convert them to the appropriate type in your component if needed (e.g.,
const id = Number(props.articleId)).Check if URL can be opened
Before opening a URL, you can check if the URL scheme is supported:Supported URL Formats
The SDK supports the following internal URL formats:choicely://special/rn/<module-name>- Opens a React Native modulechoicely://article/<content-key>- Opens an articlechoicely://contest/<content-key>- Opens a contestchoicely://feed/<content-key>- Opens a feed- And other Choicely content types
All content keys (
<content-key>) are unique identifiers created in Choicely Studio. You can find the key for each piece of content in its settings page.Example: Navigation from React Native
Here’s a complete example of navigating between different Choicely content types from React Native:This navigation system allows you to seamlessly integrate React Native content with native Choicely content, creating a unified user experience.
