browser-deeplink icon indicating copy to clipboard operation
browser-deeplink copied to clipboard

added callback option

Open godspeedelbow opened this issue 10 years ago • 6 comments

In our situation we don't want the user to go the app store but we rather provide custom callback behavior that's called when the app is not found

I also added a trailing ; after end in the android url because our Titanium app goes haywire without it.

Also, switched package and scheme for same reason

godspeedelbow avatar Feb 24 '15 15:02 godspeedelbow

I wasn't aware that when I make subsequent commits after creating a pull request, Github just adds them to the PR. Anyways, this PR gets a bit convoluted like this

godspeedelbow avatar Feb 24 '15 16:02 godspeedelbow

Great suggestion. Haven't been able to verify, but code looks like it should do the job :) However, specifying a callback should perhaps take precedence over fallback link. So I suggest changing the order of the if statement. What do you think?

if (settings.callback) {
    timeout = setTimeout(settings.callback, settings.delay);
} else if (settings.fallback) {
    timeout = setTimeout(openAppStore(Date.now()), settings.delay);
}

hampusohlsson avatar Feb 24 '15 23:02 hampusohlsson

I had it like that before but I figured I didn't want to overrule current behavior. But now that that's an option, how about we let fallback take different values:

  • 'openAppStore', opens app store (default setting, works as it does now)
  • false, don't do anything (works as it does now)
  • function() {}, call this function as a callback

godspeedelbow avatar Feb 25 '15 10:02 godspeedelbow

Yep, sounds good!

hampusohlsson avatar Feb 25 '15 10:02 hampusohlsson

The open() function is starting to get a little bloated. Perhaps we can refactor and move the settings.fallback logic to its own function?

hampusohlsson avatar Feb 25 '15 10:02 hampusohlsson

Yeah, good idea!

godspeedelbow avatar Feb 25 '15 19:02 godspeedelbow