airbnb / DeepLinkDispatch

A simple, annotation-based library for making deep link handling better on Android
http://nerds.airbnb.com/deeplinkdispatch/
4.39k stars 406 forks source link

How to compose a deeplink with parameters programmatically ? #165

Open OleksandrKucherenko opened 7 years ago

OleksandrKucherenko commented 7 years ago

Hi,

will be great to introduce API that allows to compose deeplink with parameters programmatically...

1) compose deeplink (pseudo code):

        return Uri.parse(MainActivity.DEEPLINK_SHOW_ON_MAP)
                .buildUpon()
                .clearQuery()
                .appendQueryParameter("lat", String.valueOf(latLng.latitude))
                .appendQueryParameter("lon", String.valueOf(latLng.longitude))
                .build();

2) trigger deeplink:

    /** Trigger deeplink resolving over the deep link handler activity. */
    @MainThread
    public static boolean trigger(@NonNull final Context context, @NonNull final Uri deeplink) {
        final Intent intentLink = new Intent(context, DeepLinkingActivity.class)
                .setData(deeplink);

        context.startActivity(intentLink);

        return true;
    }
Diego-Franco commented 7 years ago

+1 Is necessary for my project too, we have deeplink internally when you click some button

felipecsl commented 7 years ago

Deep links are just regular Intents with the right Uri data. You can build them yourself, not sure it's worth implementing an API for this. Just so I understand, do you want to have a builder that will correctly generate the "http://foo.bar/{var1}/{var2}" interpolations so you dont have to do it yourself?

OleksandrKucherenko commented 7 years ago

in short: YES. needed builder that recognize parameters in path and query. Maybe even recognize optional and required parameters.