And this worked fine for me, now visitng the second app on button click and it's working fine.
In the custom command, urlKey is the url of the second app i was visiting before and faced that error.