withDeepLinking.js 1.01 KB
import { createDeepLinkingHandler } from 'react-native-deep-link';
import { NavigationActions } from 'react-navigation';

let navigator;

export const setTopLevelNavigator = navigatorRef => {
    navigator = navigatorRef;
};

export const navigate = ({ routeName, params }) => {
    navigator.dispatch(
        NavigationActions.navigate({ routeName, params })
    );
};
const handleColorScreenDeepLink = ({ params: { color }, query: { textColor } }) => () => {
    console.log("A")
    navigate({
        routeName: 'MyCoupon',
        params: {
            color,
            textColor
        }
    });
};
const config= [
    {
        name: 'https:',
        routes: [
            {
                expression: 'sanggatalk.page.link/app/coupon/:id',
                callback: handleColorScreenDeepLink
            },
            {
                expression: 'sanggatalk.page.link/app/stamp/:id',
                callback: handleColorScreenDeepLink
            }
        ]
    }
]

export default createDeepLinkingHandler(config);