ionic-team / ionic-plugin-deeplinks

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: route.split is not a function

tskravisankar opened this issue · comments

We have used ionic-native deeplinks in our project by using the below link.

https://ionicframework.com/docs/v3/native/deeplinks/

While clicking the link on browser, it shows the application and once the application is clicked, it open application. But it doesn't hit on any match or nomatch response. Instead of hitting anywhere, it throws the below error

Error:
image
image

Code used:
image

IonicModule.forRoot(MyApp,
  {
    //useHash: false, 
    tabsPlacement: 'bottom',
    //locationStrategy: 'path'
  },
  { component: TapPage, name: 'tapPage', segment: 'tap'},

Version:
"ionic-angular": "3.9.2",
"@ionic-native/core": "4.7.0",
"@ionic-native/deeplinks": "^4.7.0",

Ionic version:
5.2.1

node version:
v10.15.1

Please provide us the solution to resolve this issue.

I have the same problem, any information?

Same issue here

I face this problem. Help

I rolled back to the previous version and everything worked.

  1. Remove the ios/android platform
  2. npm uninstall @ionic-native/deeplinks
  3. npm install @ionic-native/deeplinks@5.30.0

I'm having a similar issue. It looks like the code is expecting the route to be a string however its actually an Ionic Page object.

Screenshot 2021-01-26 at 12 23 20

Our code around the deeplink hasn't changed but this issue has suddenly appeared. I wonder if its changes around routing thats causing it to fail.

Looking at the recent PR's it seems it's caused by #191

@pataar yep thats exactly it.

Downgrading to version 1.0.19 seems to work.

I have following config -
"@ionic-native/core": "^4.20.0"
"@ionic-native/deeplinks": "^4.20.0"

"ionic-plugin-deeplinks": "1.0.19"

still facing this issue - "route.split is not a function"

Any solutions?

I had to go to 1.0.18 as I was still getting the issue with 1.0.19

Hi Mine got resolved with following config -
"@ionic-native/deeplinks":"^4.18.0"
"ionic-plugin-deeplinks":"^1.0.18"

I left the same version for core and deeplink. Work like a charm
"@ionic-native/core": "4.3.2",
"@ionic-native/deeplinks": "^4.3.2",

This issue is related to one line of code that appears to be incorrect in deeplinks.js. as @pataar said it's from #243

The line in deeplinks.js:
var matchedParams = self.routeMatch(pathData, realPath);

should be:
var matchedParams = self.routeMatch(targetPath, realPath);

I have confirmed that this works as normal after the change.

If anyone is looking for a real quick and dirty fix then open up deeplinks.js and swap out that line.

This issue is related to one line of code that appears to be incorrect in deeplinks.js. as @pataar said it's from #243

The line in deeplinks.js:
var matchedParams = self.routeMatch(pathData, realPath);

should be:
var matchedParams = self.routeMatch(targetPath, realPath);

I have confirmed that this works as normal after the change.

If anyone is looking for a real quick and dirty fix then open up deeplinks.js and swap out that line.

This is Also worked for me

I have the same problem, any information?

I have the same problem, any information?

If messing around with the versions of the plugin don't work (try to go at or below 1.0.18) then try Snookmz's solution for a quick fix. Since my routing however includes params the solution wasn't enough for me and I had to hard code the actual value of targetPath in the plugin to suit my needs.....

I have the same problem, any information?

If messing around with the versions of the plugin don't work (try to go at or below 1.0.18) then try Snookmz's solution for a quick fix. Since my routing however includes params the solution wasn't enough for me and I had to hard code the actual value of targetPath in the plugin to suit my needs.....

Thanks for reply. Could you please share with me your hard codes. I do not fully understand how to set targetPath.

I have the same problem, any information?

If messing around with the versions of the plugin don't work (try to go at or below 1.0.18) then try Snookmz's solution for a quick fix. Since my routing however includes params the solution wasn't enough for me and I had to hard code the actual value of targetPath in the plugin to suit my needs.....

Thanks for reply. Could you please share with me your hard codes. I do not fully understand how to set targetPath.

Here you go, I commented it as best as I could. https://github.com/jaimearrazola/custom-deeplinks
Please note this should only be a last resource attempt and you will need to reload this file manually every time you regenerate the platform

@jaimearrazola thank you very much.

I changed version from 1.0.22 to 1.0.20, my problem solved.

Hi,
Would be great to have a fix for this as it breaks all deeplinks

@jaimearrazola thank you very much.

I changed version from 1.0.22 to 1.0.20, my problem solved.

what is your version for the following?
"@ionic-native/core"
"@ionic-native/deeplinks"

@jaimearrazola thank you very much.
I changed version from 1.0.22 to 1.0.20, my problem solved.

what is your version for the following?
"@ionic-native/core"
"@ionic-native/deeplinks"

"@ionic-native/core": "^4.20.0"
"@ionic-native/deeplinks": "^4.20.0"

@jaimearrazola thank you very much.
I changed version from 1.0.22 to 1.0.20, my problem solved.

what is your version for the following?
"@ionic-native/core"
"@ionic-native/deeplinks"

"@ionic-native/core": "^4.20.0"
"@ionic-native/deeplinks": "^4.20.0"

Thank you!

I am facing this problem too, here is what I run:
"@ionic-native/core": "^5.31.1",
"@ionic-native/deeplinks": "^5.31.1",
"ionic-plugin-deeplinks": "^1.0.22"
I have tried all the wirkarounds mentioned above, almost every combination of versions, I still have the same problem
Also, I don't know if this could be of help, but in the console.log, the "route.split is not a function" becomes "TypeError: Cannot read property 'length' of undefined" after 2 seconds", that's until I click on the deeplink again

@whitymighty For me it was really crucial to not just downgrade, but really to remove and reinstall all platforms as the scripts in there won't get updated automatically.

@whitymighty For me it was really crucial to not just downgrade, but really to remove and reinstall all platforms as the scripts in there won't get updated automatically.

I did that with every version/deeplink.js edit and still face the same problem

@whitymighty Last guess that I have, is to check the plugins folder after the downgrade to see if the downgrade was successful. Hope it helps!

@mgreg89 Sadly that also didn't work, thank you so much for trying tho.
here's a recap for everyone:
"ionic-plugin-deeplinks": "^1.0.20"
"@ionic-native/core": "5.20.0"
"@ionic-native/deeplinks": "5.20.0"

Deleted the node_module and plugins folders, deleted the platforms, edited the deeplink.js as @Snookmz suggested, and I am still facing the same problem

Okay, so I figured out the problem. It turns out that ionic 4 does not support routing from the deeplink like:
"this.deeplinks.routeWithNavController(this.navCtrl, {
'/products/:productId': ProductPage
}).subscribe(match => {"
Importing the page to redirect to is apparently deprecated and causes the "route.split is not a function" error.
All I did was that I quoted the ionic pages's name.
Though to be I am not sure if toying around with the versions actually helped.
I hope this fixes the problem for whoever goes through the same. Peace

#242 should fix this issue as well. Still waiting for it to be approved and merged. In the meanwhile, we're using this patch as a temporary fix.

This issue is related to one line of code that appears to be incorrect in deeplinks.js. as @pataar said it's from #243

The line in deeplinks.js:
var matchedParams = self.routeMatch(pathData, realPath);

should be:
var matchedParams = self.routeMatch(targetPath, realPath);

I have confirmed that this works as normal after the change.

If anyone is looking for a real quick and dirty fix then open up deeplinks.js and swap out that line.

Hey this is still not working for me , need help

#242 should fix this issue as well. Still waiting for it to be approved and merged. In the meanwhile, we're using this patch as a temporary fix.

hey is this closed?

What's the final fix? I see the same issue with updated plugin

"@ionic-native/core": "5.0.0",
"@ionic-native/deeplinks": "^5.0.0",
plugin version ^1.0.18

fixed my issue

Any update on this issue ?

Any update on this?

1.0.20 worked for me after I found that Ionic Build was using 1.0.22 although I had 1.0.20 specified in package.json. This was because my project did not have a package-lock.json included to make sure the exact version I installed was used.

as there is still no fix for this bug, I would like to share my temporary solution:

I had something like:

const deeplinkList = {
	'/products/all': ProductsComponent,
	'/product/:id': ViewProductComponent,
};

this.deeplinks.routeWithNavController(nav, deeplinkList)
	.subscribe(match => {}, nomatch => {
		console.error("nomatch for deeplink: ", nomatch);
	});

that I had to convert in something like:

const deeplinkList = {
	'/products/all': "ProductsComponent", // a string here will avoid that split error to be thrown.
	'/product/:id': "ViewProductComponent",
};

this.deeplinks.routeWithNavController(nav, deeplinkList)
	.subscribe(match => {
		const matchData = match['$link'];
		// matchData is now a object like:
	/*
		host: "products"
		path: "/all"
		queryString: ...
		scheme: "..."
		url: "..."
	*/
		// with this data I manually redirect to Products Component on my own rules in this function

	}, nomatch => {
		console.error("nomatch for deeplink: ", nomatch);
	});

It seems this fix was not merged in 1.0.23, how is it possible to use the plugin with this redirect bug ?

Does someone have a PR for this? We can look at and merge it and get a new release out

Does someone have a PR for this? We can look at and merge it and get a new release out

this seems to fix the bug #242

Out in 1.0.24 thanks