Giter VIP home page Giter VIP logo

Comments (3)

luisfcofv avatar luisfcofv commented on August 22, 2024 2

@StuffWeDoCo The library works for both platforms, it's not iOS only. The docs are updated for both platforms. However, the example provided only shows iOS.

Feel free to send a pull request if you are feeling useful.

from react-native-deep-linking.

blaues0cke avatar blaues0cke commented on August 22, 2024 1

For anyone that lands here after some googeling, this seems to work. Based on the case you want to call test://lost-password:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:launchMode="singleTask"
>
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
    <intent-filter android:label="filter_react_native">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="test"
              android:host="lost-password"/>
    </intent-filter>
</activity>

The basic difference to https://developer.android.com/training/app-links/deep-linking is this line: android:launchMode="singleTask".

In my case I wrote a middleware for redux to then decide whether I want to open a route or not:

import _                     from 'lodash';
import DeepLinking           from 'react-native-deep-linking';
import { Linking }           from 'react-native';
import Screens               from '../../constants/Screens';
import { NavigationActions } from 'react-navigation';
import { REHYDRATE }         from 'redux-persist';

DeepLinking.addScheme('test://');

const handleUrl = ({ url }) => {
    Linking.canOpenURL(url).then((supported) => {
        if (supported) {
            DeepLinking.evaluateUrl(url);
        }
    });
};

Linking.addEventListener('url', handleUrl);

function deepLinkingMiddleware () {
    return ({ dispatch, getState }) => next => action => {
        if (action.type === REHYDRATE) {
            DeepLinking.addRoute('/lost-password/:token', (response) => {
                dispatch(NavigationActions.navigate({
                    params:    {
                        token: response.token,
                    },
                    routeName: Screens.ResetPassword,
                }));
            });
        }

        return next(action);
    };
}

export {
    deepLinkingMiddleware,
};

To test this you can use this command:

adb shell am start -a android.intent.action.VIEW -d "test://lost-password/foo" de.your-package.id

from react-native-deep-linking.

StuffWeDoCo avatar StuffWeDoCo commented on August 22, 2024

Cmon...... if you're going to provide a 'react-native' library, then make sure the docs are updated for both platforms. Otherwise, mark it as [iOS Only]

from react-native-deep-linking.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.