Jumping between remote applications using the cordova (complex problem)

1

Hello,

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

In order to achieve this, I need to get the code from each of the applications 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 native controls of the phonegap and as such needs to have imported into the source code the file cordova.js or phonegap.js

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

When moving the applications to different servers, some problems arise due to these simple functional requirements:

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

Problems: - My remote apps are hosted on your 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 can not authorize CORS, when I open the application in InAppBrowser the applications can not communicate with the API, because the domain of the application that we are accessing is different from the api domain (ex: A.com! = C.com logo = > We have CORS). Typically, this problem does not exist if we get 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 this, and without solving the problem of how to access the application controls I get the idea of putting different versions of the application on the server where each one of them makes the host of the file phonegap.js for the platform that did the order.

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 the 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 though this solution works, I'm still not sure how to get back to the local application.

Does anyone have ideas that can help solve these problems? I hope it was not too confusing, the problem is complex

    
asked by anonymous 11.03.2015 / 23:13

1 answer

2

Actually the problem is quite complex, actually got up a little confusing. But I believe you have answered your question.

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

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

  

In order to achieve this, I need to get the code from each of the applications and move it to a server so that this fourth application can redirect between apps.

Not exactly, you should adapt an application (or port) so that it works on a Server , for this you can use the language you want, the point is that at some point in this application inside 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:

link

It should be noted that there are a lot of people who do not recommend setting URI Scheme because it goes against the standards, more information in this link , however you can send information between applications on the server.

If you are doing an application with Cordova and just putting the files (HTML, CSS, JavaScript) on a server and calling them in Cordova, you may need to rethink your strategy, as well as the numerous problems this can cause, such 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) of a server, but the application has autonomy to validate / verify the data and report errors (lack of connection, broken files).

On the CORS problem, if the server administrator does not authorize CORS, the best solution would be to switch servers, there are forms of bypass using proxy requests on another server with other technologies , but if the same problem is the administrator not allowing it, it will probably also block any other alternative.

About your idea of making JavaScript local to the domain by changing its request and avoiding the use of CORS. You can really make Cordova identify the platform and provide the best file for it, however it is not the best solution, you are making the problem that is already complex into something more complex 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 treatment of information, device version checks, calls to other applications and / or screens. In order to centralize your data in a single location and keep different applications in their own scope.

If I did not understand your question, or got confused at something, please disregard.

    
13.03.2015 / 15:39