RodrigoSMarques / flutter_branch_sdk

Flutter Plugin for create deep link using Branch Metrics SDK. This plugin provides a cross-platform (iOS, Android, Web).
https://branch.io
MIT License
100 stars 90 forks source link

Alternate solution for poor network connectivity error due to AdBlock #271

Closed dinoleonetti closed 10 months ago

dinoleonetti commented 11 months ago

Which problem is this feature request solving?

Alternate solution for poor network connectivity error due to AdBlock

Describe the solution you'd like

This could be fixed by the plugin returning to the app the link that was received, so the app could access Branch.io through a gateway

Describe alternatives you've considered

Couldn't think of any alternative solution.

Can you submit a pull request?

Yes we could. https://github.com/facily-tech/flutter_branch_sdk/pull/3/files

More detailed explanation below:

About 5% of our user base has AdBlock active on their smartphones and our app that relies on Branch.io for deeplinks does not function properly.

We discussed this with Branch.io support looking for alternate solutions, but there is no support regarding service unavailability due to AdBlock restrictions.

We tried an alternate solution:

  1. at boot, app posts to Branch.io public url and if it is not reachable, we turn a fallback flag on
  2. if fallback is turned on:
    • on generate link, the app sends the link object to a gateway on our domain, this gw redirects to branch public api, and returns the response to the app
    • when deeplink is received, we faced another problem: the plugin does not provide (or at least we couldn't figure out) a way to access the link that did not work due to AdBlock restrictions (so we could send the link to our gateway and redirects to Branch.io to return the link object).

So what we needed from the plugin was access to the link that was received. We did this in the repository below (version 7.0.1), and we are already running successfully in production (20% of our userbase of 1.2M phones) for a few weeks. We also did this in version 6.7.1 and was running in beta test (30k users) a few weeks ago, but for production, we updated the solution to version 7.0.1.

We are hoping that this is interest enough so that you will consider including it in future versions so it could help other people (and also reduce our burden to replicate this every time we update the plugin version). We have seen many people complaining about AdBlock restrictions in the past, but unfortunately, no solution has been provided. This is a very restricted solution where the plugin just provides the app with the last link it received.

I even hope that with your broad understanding of the plugin you could come up with a better solution than the one we presented, and it would be much appreciated.

RodrigoSMarques commented 11 months ago

Hi @dinoleonetti If you create a PR and update REAME.MD with the usage explanation, I see no problem with merging it into the plugin code.

I've been checking some methods in the Branch SDK code, and I found the methods below that can help direct all requests directly to the gateway, without having to handle fallback.

     /**
      * <p>Sets a custom base URL for all calls to the Branch API. Requires https.</p>
      * @param url The {@link String} URL base URL that the Branch API uses.
      */
     public static void setAPIUrl(String url) {
         PrefHelper.setAPIUrl(url);
     }

     /**
      * <p>Sets a custom CDN base URL.</p>
      * @param url The {@link String} base URL for CDN endpoints.
      */
     public static void setCDNBaseUrl(String url) {
         PrefHelper.setCDNBaseUrl(url);
     }

I can also expose these two methods in the plugin if it works.

RodrigoSMarques commented 11 months ago

        Branch.setAPIUrl("https://mygateway.com/api/");
        Branch.registerPlugin(PLUGIN_NAME, (String) argsMap.get("version"));
        Branch.getAutoInstance(this.context);
RodrigoSMarques commented 10 months ago

Closed. No activity in the last 15 days. If necessary open again.