sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7.01k stars 435 forks source link

Firebase dynamic links #1778

Closed unicornlab-sivap closed 3 years ago

unicornlab-sivap commented 3 years ago

Do we have any helper functions to handle Firebase dynamic links in the Svelte + Sapper app? https://firebase.google.com/docs/dynamic-links We want to take the user to a particular screen instead of the landing page.

I found firebase plugins for flutter, Cordova.

Flutter plugin

https://pub.dev/packages/firebase_dynamic_links
void initDynamicLinks() async {
    FirebaseDynamicLinks.instance.onLink(
      onSuccess: (PendingDynamicLinkData dynamicLink) async {
        final Uri deepLink = dynamicLink?.link;

        if (deepLink != null) {
          Navigator.pushNamed(context, deepLink.path);
        }
      },
      onError: (OnLinkErrorException e) async {
        print('onLinkError');
        print(e.message);
      }
    );

    final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
    final Uri deepLink = data?.link;

    if (deepLink != null) {
      Navigator.pushNamed(context, deepLink.path);
    }
  }

Cordova Plugin

https://www.npmjs.com/package/cordova-plugin-firebase-dynamiclinks

getDynamicLink
Determines if the app has a pending dynamic link and provide access to the dynamic link parameters.

cordova.plugins.firebase.dynamiclinks.getDynamicLink().then(function(data) {
    if (data) {
        console.log("Read dynamic link data on app start:", data);
    } else {
        console.log("App wasn't started from a dynamic link");
    }
});
onDynamicLink(callback)
Registers callback that is triggered on each dynamic link click.

cordova.plugins.firebase.dynamiclinks.onDynamicLink(function(data) {
    console.log("Dynamic link click with data:", data);
});
Conduitry commented 3 years ago

GitHub issues aren't the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room.