Code Monkey home page Code Monkey logo

Comments (9)

rlepinski avatar rlepinski commented on September 25, 2024 1

@JackRKelly I passed on your recommendation to our docs team

from airship-flutter.

rlepinski avatar rlepinski commented on September 25, 2024

We have two actions that handle URLs - deep link and open external url action. Open external urls are assumed to be external while deep links are internal. Do you know which one is being used? If you can provide the message HTML I could see what action is being ran.

from airship-flutter.

JackRKelly avatar JackRKelly commented on September 25, 2024

We are using the open external link.

<a href="uairship://run-actions?open_external_url_action=%22http%3A%2F%2Famc.film%2F2pIvfo9%22">
    <span>Click Here</span>
</a>

But it seems the OS refuses to reopen the app it came from after following that link. Which again, is why we handle the navigation events in the WebView widget and explicitly search URIs for our deep link scheme.

When trying to use a "Deep Link" as opposed to a "Web Page"/external link. The button isn't clickable, I have tested this on a physical device and simulator. See the HTML for the deep link button below:

<a href="uairship://run-actions?deep_link_action=%22http%3A%2F%2Famc.film%2F2pIvfo9%22">
    <span>Click Here</span>
</a>

from airship-flutter.

rlepinski avatar rlepinski commented on September 25, 2024

I am not sure why it would not be clickable? It looks the same to me. Could you remote debug the webview to see whats causing it to not be clickable?

The quickest path would be to resolve this instead of coming up with a different solution.

from airship-flutter.

JackRKelly avatar JackRKelly commented on September 25, 2024

I believe that was just a local issue on my end.

For our previous application, we updated a predicate for open_external_url_action (See "Setting a predicate" here: https://docs.airship.com/platform/ios/actions/).

The code looked like:

UAirship.Shared.ActionRegistry.UpdatePredicate(predicate, "open_external_url_action");

But in the documentation for the flutter SDK, there is no actions page, as I assume it has not been implemented.

And the uairship run action deep link isn't working (it is clickable, but doesn't navigate as expected). So we are expecting a way to handle open_external_url_action.

from airship-flutter.

rlepinski avatar rlepinski commented on September 25, 2024

The deep link action, assuming we can get that to work, should do what you want to do here. You can use it for everything and the URLs you want to open externally you can from the deep link handler. How are you implementing the deep link listener?

from airship-flutter.

JackRKelly avatar JackRKelly commented on September 25, 2024

We have implemented the deep link handler with the follow snippets below (with some non-critical logic removed):

class DeepLinkService {
  final GetNavigationService _get;
  final BitlyService _bitlyService;
  final AnalyticsService _analyticsService;

  final _appLinkStreamController = StreamController<AppLink?>.broadcast();
  Stream<AppLink?> getAppLinkStream() => _appLinkStreamController.stream;

  late StreamSubscription<Uri?> _stream;

  DeepLinkService(
    this._get,
    this._bitlyService,
    this._analyticsService,
  );

  Future<void> start() async {
    try {
      logger.info('Deep Link Service Started');

      final initialUrl = await getInitialUri();
      onUriReceived(initialUrl);

      _stream = uriLinkStream.listen((uri) {
        onUriReceived(uri);
      });
    } catch (e) {
      logger.error('Error attempting to start DeepLink Service', exception: e);
    }
  }

  Future<void> stop() async {
    return _stream.cancel();
  }

  Future<void> onUriReceived(Uri? uri) async {
    try {
      if (uri != null) {
        logger.info('Deep Link Received ${uri.toString()}');

        if (uri.host != 'amc.film') {
          _appLinkStreamController.sink.add(
            AppLink(uri: uri),
          );

          return;
        }

        final expandedUri = await _bitlyService.expand(uri.toString());

        _analyticsService.reportDeepLink(expandedUri);

        //Authentication guard
        final authedRouteFound = _matchAuthRoute(expandedUri);

        if (authedRouteFound && AuthenticationService.user.isLoggedOut()) {
          var user = await _get.toNamed(LoginPage.route());

          if (user == null) {
            return;
          }
        }

        await _get.routeFromExternalUrl(expandedUri);
      }
    } catch (ex) {
      logger.error('Error receiving deep link', exception: ex);
    }
  }
}

We are including it in our providers in our main app file:

  List<SingleChildWidget> _providers() {
    return [
      ProxyProvider3<GetNavigationService, BitlyService, AnalyticsService, DeepLinkService>(
        update: (_, get, bitly, analyticsService, previous) => previous ?? DeepLinkService(get, bitly, analyticsService),
        dispose: (_, service) => service.stop(),
      ),
      // Other entries hidden
    ];
  }

And we are initializing it in the view model of our splash screen:

  @override
  Future<void> onLoad() async {
    _deepLinkService.start();
  }

Hopefully these snippets help paint the picture of our implementation. If you need more context, let me know. Thanks!

from airship-flutter.

rlepinski avatar rlepinski commented on September 25, 2024

@JackRKelly You need to register for Airship's deep links:

Airship.onDeepLink
    .listen((deepLink) {
        Uri uri = Uri.parse(deepLink);
        onUriReceived(uri);
    });

from airship-flutter.

JackRKelly avatar JackRKelly commented on September 25, 2024

@JackRKelly You need to register for Airship's deep links:

Airship.onDeepLink
    .listen((deepLink) {
        Uri uri = Uri.parse(deepLink);
        onUriReceived(uri);
    });

Awesome! This has fixed it. I was unaware I had to register that listener. May I recommend adding a snippet (to recommend the developer check if they have attached a listener) to the manage deep links page?

from airship-flutter.

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.