NativeScript icon indicating copy to clipboard operation
NativeScript copied to clipboard

Feature request: Linking interface

Open jdnichollsc opened this issue 6 years ago • 12 comments

It's a common problem to detect redirections via deep linking and it would be awesome to have a core Interface to reuse the logic, also it's very useful creating plugins to detect that for all platfoms (Android & iOS).

Describe the solution you'd like Create something like this: https://facebook.github.io/react-native/docs/linking Linking gives you a general interface to interact with both incoming and outgoing app links. Common methods:

  • openURL (It's already supported from tns-core-modules/utils/utils)
  • canOpenURL (Determine whether or not an installed app can handle a given URL.)
  • addEventListener (Add a handler to Linking changes by listening to the url event type and providing the handler)

Alternatives you've considered:

Additional context What do you think to support deep link paths from the navigation too?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

jdnichollsc avatar May 16 '19 15:05 jdnichollsc

@jdnichollsc - NS tries to keep the core fairly small and lean.

Most apps don't need deep linking, so I don't understand the issue if their is a plugin that already solves the issue... Deep linking really isn't a core feature; it is imho a plugin feature. :grinning:

NathanaelA avatar May 16 '19 16:05 NathanaelA

@NathanaelA but you can't remove the listeners from those plugins and Oauth authentication (deep linking is required for this) is a very common situation for mobile apps :/ On the other hand, from iOS platform other plugins can override application.ios.delegate and that's a problem here, what do you think?

jdnichollsc avatar May 16 '19 17:05 jdnichollsc

I mean Can you guys analyze the possibility of this? It would be very helpful having a general interface to interact with both incoming and outgoing app links. 🙏

jdnichollsc avatar May 16 '19 17:05 jdnichollsc

Well the ios framework delegate issue is an issue that the core team and I have debated many times of the last four years; I even had a PR that was rejected because they didn't like the way I was trying to easily open up access to the delegates outside of the framework (for plugins) -- and imho it still is the second best way to solve the whole issue (no breaking changes, and would allow plugins access right now without breaking each other, so it is still the best way for quickly moving forward without breaking anything)... The actual best way to solve this issue is some major reworking, and maybe they will consider it for NS 8 or 10 (as it would be breaking changes if I recall correctly). I don't see issue being solved anytime soon, since we have been debating it since before NS 2, it is imho one of the biggest issues with extending the iOS side of the framework... :frowning_face:

If you created a PR, they might be willing to accept it, but for them to even consider adding your PR, it has to offer them something that a plugin can't (normally) and be code that can be easily maintained without breaking or complicating things..

As an example; Android 6+ requires most permissions are asked for at runtime. This would be a feature that would be great in the framework, as almost every Android app needs it at some point. They have even probably debated it internally several times on if they should just subsume my ns-permissions plugin and integrate it inside the framework. It is a very stable permissions plugin for Android, and works for virtually every permission known to man. :grinning: However, by leaving it outside of the framework; they don't have to maintain it. The community maintains it and it is simple to add to your project. Even some plugins use it as a dependency.

For them to add it, it has to be a feature that is more important than most other framework work -- i.e. the work has to be justified taking it from other open PR's and issues... In my humble opinion, this feature is not something I would have them work on; there are considerably way more important things (like the delegate access system I mentioned above... :grinning:) than this feature which I've never once needed to use in so far about 20 clients apps. :grinning:

So all that to say, ask them if they would be willing to take a PR for this feature, if they are -- make the PR... :grinning:

NathanaelA avatar May 16 '19 17:05 NathanaelA

I would like to know your opinion first, if it makes sense to make that effort, I just consider it an opportunity for improvement compared to the utilities that React Native has and they are precisely moving a lot of components to the React Native Community https://github.com/react-native-community to make the Core as clean as possible.

jdnichollsc avatar May 16 '19 23:05 jdnichollsc

@NathanaelA @NickIliev I agree that maybe it is better to have it as a plugin, but would be nice to have it as an official plugin from nativescript, since the last plugin nativescript-urlhandler has been abandoned

Jonatthu avatar Dec 09 '19 23:12 Jonatthu

@Jonatthu - Not sure NS-urlhandler has been abandoned yet -- it was updated only a month ago...

NathanaelA avatar Dec 10 '19 01:12 NathanaelA

Maybe he's talking about this comment https://github.com/hypery2k/nativescript-urlhandler/issues/88#issuecomment-534251491

jdnichollsc avatar Dec 10 '19 06:12 jdnichollsc

@NathanaelA Last was 6 months ago plus this comment confirms https://github.com/hypery2k/nativescript-urlhandler/issues/88#issuecomment-534251491

Jonatthu avatar Dec 10 '19 06:12 Jonatthu

Ah, thanks for the link. This plugin might be a good candidate to join the awesome ProPlugins. :grinning:

NathanaelA avatar Dec 10 '19 17:12 NathanaelA

@NathanaelA Please would be great!

Jonatthu avatar Dec 10 '19 22:12 Jonatthu

Also, I think we need the possibility to remove listeners, like removeEventListener method or something like that to remove subscriptions detecting deep linking redirections :)

E.g:

_handleOpenURL(event) {
  console.log(event.url);
}
ngOnInit() {
  Linking.addEventListener('url', this._handleOpenURL);
}
ngOnDestory() {
  Linking.removeEventListener('url', this._handleOpenURL);
}

jdnichollsc avatar Dec 11 '19 00:12 jdnichollsc