Jumping between remote applications using Cordova (complex problem)

Asked

Viewed 123 times

1

Hello,

I have 3 apps and each one is available for iOS and Android and would like to create an app to access all of them.

To achieve this, I need to take the code of each application and move it to a server so that this fourth application can redirect between apps.

It is important to mention that each application needs to access the phonegap native controls and as such needs to have imported the Cordova.js or phonegap.js file into the source code.

It turns out that when we compile an application that file is injected into the directory according to the platform for which we are compiling.

When moving applications to different servers some problems arise that are due to these simple functional requirements:

  • Local application allows you to open remote applications
  • Remote applications can access device controls and plugins installed on it
  • From any remote application it should be possible to return to the local application

Problems: - My remote applications are hosted in their own domain such as a.com, b.com, c.com. All applications communicate with an api that is in the d.com. domain As the administrator cannot authorise CORS, when I open the application in Inappbrowser the applications cannot communicate with the API, because the domain of the application we are accessing is different from the domain of the api (ex: A.com != c.com logo => We have CORS). Typically, this problem does not exist if we take the code found in any of these applications: ("a.com"... "c.com") and compile it because the applications are no longer hosted on a server.

  • Having said that, and without solving the problem of how to access the application controls, I came up with the idea of placing different versions of the application on the server where each of them hosts the phonegap.js file for the platform that made the request.

Example: When opening application 4 the application detects that we are using an android and will create dynamic links that allow me to the project that has in its directory phonegap.js for Androids.

in other words: a. com/android <----- has a phonegap.js for Androids a. com/Ios <---- has a phonegap.js for Ios

Even if this solution works I still don’t know how to get back the local application.

Does anyone have any ideas that could help solve these problems? I hope it wasn’t too confusing, the problem is complex

1 answer

2

Actually the problem is very complex, actually it got a little confusing. But I believe you’ve answered your question.

You have several applications for iOS and Android, you want to create a form of integration between applications, so you have developed a new remote application in order to switch between local applications (or installed on devices).

The first point I must raise is in relation to the following:

To achieve this, I need to take the code of each application and move it to a server so that this fourth application can redirect between apps.

Not exactly, you must adapt an application (or port) for it to work in a Server, for this you can use the language you want, the point is that at some point in this application within the Server you must make calls to the applications within the devices. For this you can use URI Schemas, there are even plugins already ready for Cordova:

https://github.com/EddyVerbruggen/Custom-URL-scheme

It is worth mentioning that there are many people who do not recommend defining URI Scheme since it goes against the standards, more information in this link, but with this you can send information between applications on the server.

If you are making an application with Cordova and just putting the files (HTML, CSS, Javascript) on a server and calling them in Cordova, maybe you should rethink your strategy, in addition to the numerous problems that this can cause, as lack of compatibility and broken files. What you should do is create an application that only requests the data (or even the complete pages) from a server, but the application has the autonomy to validate/verify the data and report errors (lack of connection, broken files).

About the problem of CORS, if the administrator of the server does not authorize CORS, the best solution would be to change server, there are ways of "bypass" using a proxy of requests on another server with other technologies, but if the problem is the administrator not allowing, it will probably also block any other alternative.

About his idea to make Javascript local for the domain by changing its request and avoiding the use of CORS. You can actually make Cordova identify the platform and provide the best file for it, but it is not the best solution, you are making the problem that is already complex into something more complex yet and added more risks of problems with version compatibility.

From my point of view the best strategy is to create a Webservice just to exchange information between local applications. No JS file requests or any other format, just data. And within each application would be the processing of information, device version checks, calls to other applications and/or screens. In order to centralize your data in a single location and maintain different applications in their own scope.

If I don’t understand your question, or I’m confused about something, please disregard.

  • Thanks for the reply Enrique. I will carefully check your suggestions and return to give feedback

Browser other questions tagged

You are not signed in. Login or sign up in order to post.