hypery2k / nativescript-urlhandler

NativeScript URL Handler Plugin
MIT License
52 stars 34 forks source link

I always get blank component page when I call router.navigateByUrl() in handleOpenURL()? #71

Closed indianazhao closed 6 years ago

indianazhao commented 6 years ago

What did you do?

I try to call router.navigateByUrl('targetComponent') in handleOpenURL(), but I always got a blank component page without console log.

What did you expect to happen?

I can get the appURL in handleOpenURL() and I would like to navigate to some target router with some console log for the target component initialization.

What happened instead?

I just got a blank component page with back button in the header. If I click the back button, it will go to the entry component with all console log which should print out during the target component life cycle.

Your Environment

NativeScript version: 3.3.0-2017-10-16-9974 Java version: 1.8.0_144 NodeJS and NPM version: 7.4.0 and 4.0.5 Platform(s) running: Android

Demo Project

N/A

indianazhao commented 6 years ago

It seems to be the iOS delegate conflict issue (with the plugin 'nativescript-facebook'). I'm not familiar with iOS development. Is it possible to have multiple iOS delegate in the same app?

hypery2k commented 6 years ago

mmh not it's no allowed, but I currently don't have a solution for this issue

indianazhao commented 6 years ago

I'm still very thank you for this plugin even now I only use it for android platform.

hypery2k commented 6 years ago

could you give Version 1.2.2 a try?

indianazhao commented 6 years ago

I've tried 1.2.2 but I still get the blank page with only header info. The following codes show how I handle the deep link url:

ngOnInit() {
    const self = this;
    handleOpenURL((appURL: AppURL) => {
        if (appURL.path) {
            var parts = appURL.path.split('/');
            if (parts && parts.length >= 2) {
                self.router.navigateByUrl('group/' + parts[parts.length - 1]);
            }
        }
    });
}

I can parse the appURL and navigate to target component. But the content is blank: image

The content can be rendered again after I click the top-right refresh button. image

This only occur in iOS.

  1. Open url (deep link) in browser.
  2. Open my app (Menu with 6 big blue button).
  3. Parse the url and navigate to the target component.
  4. Target component with blank content.
  5. Click refresh button to reload content.

ezgif-2-24b7d9cdc8

hypery2k commented 6 years ago

seems to be like an angular issue as the data is correct handled. Maybe you have to wrap it in in a zone:

this.zone.run(() => {
   self.router.navigateByUrl('group/' + parts[parts.length - 1]);
});
indianazhao commented 6 years ago

Wow! It solves the problem. I will do some study on zone. Thank you very much!

hypery2k commented 6 years ago

glad to help.