Skip to content

Instantly share code, notes, and snippets.

Avatar
Working from home

Nishant Neeraj naishe

Working from home
View GitHub Profile
@naishe
naishe / App.jsx
Created Dec 6, 2020
Deep Linking Push Notifications with React Navigation #0
View App.jsx
// 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
@naishe
naishe / App.tsx
Created Dec 6, 2020
Deep Linking Push Notifications with React Navigation #6
View App.tsx
// 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);
@naishe
naishe / App.tsx
Created Dec 6, 2020
Deep Linking Push Notifications with React Navigation #5
View App.tsx
// 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();
@naishe
naishe / open-app.sh
Last active Dec 6, 2020
Deep Linking Push Notifications with React Navigation #4
View open-app.sh
# 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
@naishe
naishe / App.tsx
Last active Dec 6, 2020
Deep Linking Push Notifications with React Navigation #3
View App.tsx
// App.tsx
// Deep links
const deepLinksConf = {
screens: {
HomeRoutes: {
initialRouteName: 'Home',
screens: {
Settings: 'settings',
Comics: 'comics/:comicsId',
@naishe
naishe / App.tsx
Last active Dec 6, 2020
Deep Linking Push Notifications with React Navigation #1
View App.tsx
// App.tsx
const App = () => {
return (
<NavigationContainer>
{/** Your routes here */}
<LoginSignupRoutes />
<HomeRoutes />
</NavigationContainer>
);
}
@naishe
naishe / AndroidManifest.xml
Last active Dec 6, 2020
Deep Linking Push Notifications with React Navigation #2
View AndroidManifest.xml
<!-- File Name: android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.app.package.name">
<!-- redacted permissions and other tags -->
<application >
<activity >
<!-- redacted other intent filters -->
<!-- this intent filter handles myapp:// scheme -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
@naishe
naishe / SyncStatus.ts
Created Aug 5, 2020
CodePush Integration
View SyncStatus.ts
enum SyncStatus {
/**
* The app is up-to-date with the CodePush server.
*/
UP_TO_DATE,
/**
* An available update has been installed and will be run either immediately after the
* syncStatusChangedCallback function returns or the next time the app resumes/restarts,
* depending on the InstallMode specified in SyncOptions
@naishe
naishe / VersionInfo.tsx
Created Aug 4, 2020
CodePush Integration: UI to switch Versions
View VersionInfo.tsx
import React, {useState} from 'react';
import {StyleSheet, View, Switch, ActivityIndicator} from 'react-native';
import {Text, ThemeProps, ThemeContext} from 'react-native-elements';
import codePush, {LocalPackage} from 'react-native-code-push';
import AsyncStorage from '@react-native-community/async-storage';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {
CODEPUSH_STAGING_DEPLOYMENT_KEY,
CODEPUSH_PRODUCTION_DEPLOYMENT_KEY,
} from '../utils/constants';
@naishe
naishe / costants.ts
Created Aug 4, 2020
CodePush Deployment Keys
View costants.ts
// CODEPUSH RELATED DATA
export const CODEPUSH_STAGING_DEPLOYMENT_KEY = 'jhai-muzz27Nt7Y11KLp-cBsNA22EGjGHEYfr';
export const CODEPUSH_PRODUCTION_DEPLOYMENT_KEY = 'Jbach1Qk_achQarrrhNOA9zwVlJnruLsa9jsr';