View SomeComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{/** Relative path of package.json from the component */} | |
<Text>{require('../../package.json').version}</Text> |
View package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"android": "react-native run-android", | |
"ios": "react-native run-ios", | |
"start": "react-native start", | |
"test": "jest", | |
// Append this new lifecycle script | |
"postversion": "cd android && ./gradlew bundleRelease" | |
}, |
View build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultConfig { | |
applicationId YOUR_APPLICATION_ID | |
minSdkVersion rootProject.ext.minSdkVersion | |
targetSdkVersion rootProject.ext.targetSdkVersion | |
// UPDATE THESE VALUES WITH THE FUNCTION CALLS | |
versionCode getNumericVersionFromNpm() | |
versionName getVersionFromNpm() | |
} |
View build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import JSON parser, place it at the top of the file | |
import groovy.json.JsonSlurper | |
// Read package.json and return `version` field | |
def getVersionFromNpm() { | |
// Read and parse package.json file from project root | |
def inputFile = new File("$rootDir/../package.json") | |
def packageJson = new JsonSlurper().parseText(inputFile.text) | |
View App.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple scenario without nested routes, without path parameters | |
function App() { | |
const navigation = useNavigation(); | |
const [loading, setLoading] = useState(true); | |
const [initialRoute, setInitialRoute] = useState('Home'); | |
useEffect(() => { | |
// Assume a message-notification contains a "type" property in the data payload of the screen to open |
View App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.tsx | |
// only new changes shown, refer: https://gist.github.com/naishe/46dfb1e23612398e4bd525f03c001dd9 | |
const linking: LinkingOptions = { | |
prefixes: ['myapp://', 'https://app.myapp.com'], | |
config: deepLinksConf, | |
async getInitialURL() { /* redacted */ }, | |
subscribe(listener) { | |
const onReceiveURL = ({url}: {url: string}) => listener(url); |
View App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.tsx | |
// only new changes shown, refer: https://gist.github.com/naishe/da4830b72eeb81f8a5e29b6e45692d86 | |
const linking: LinkingOptions = { | |
prefixes: ['myapp://', 'https://app.myapp.com'], | |
config: deepLinksConf, | |
async getInitialURL() { | |
// Check if app was opened from a deep link | |
const url = await Linking.getInitialURL(); |
View open-app.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming you have a key, “settings”, configured in your | |
# linking config that points to a valid screen | |
# The following command should show you a popup asking | |
# which app you want to use to open this link and offer you | |
# two options (normally) between the browser and your app. | |
npx uri-scheme open https://app.myapp.com/settings --android | |
# The following command should open your app | |
# and lands you on the settings page |
View App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.tsx | |
// Deep links | |
const deepLinksConf = { | |
screens: { | |
HomeRoutes: { | |
initialRouteName: 'Home', | |
screens: { | |
Settings: 'settings', | |
Comics: 'comics/:comicsId', |
View App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.tsx | |
const App = () => { | |
return ( | |
<NavigationContainer> | |
{/** Your routes here */} | |
<LoginSignupRoutes /> | |
<HomeRoutes /> | |
</NavigationContainer> | |
); | |
} |
NewerOlder