user3392750
user3392750

Reputation: 41

How to use google-cast for Android and iOS together with Cordova for a mobile webapp?

We have an Android-App and an iOS-App, both are not native apps, they are build with Apache Cordova. In the documentation for the Chromecast Sender Apps, I see that the lifecycle in the Google Cast SDK for Android and for iOS is different. Now we are wondering, if it is possible to use a Cordova-Plugin that will work for Android and for iOS.

Do you have some experience, how to integrate the Chromecast-API with Cordova. Do you know plugins, that we could use? Or would you generally recommend to use the Chromecast APIs only in native apps? Do you see any technical problems to integrate the chromecast functionality in an app, that is build with Cordova, that only displays the mobile webpage?

In worst case I see three different "applications" that we have to implement. One for Android, one or iOS and one for the desktop. The third one, only if we want to support the chrome-browser with its chromcast-plugin, too. Do you agree with that?

Upvotes: 4

Views: 2107

Answers (2)

Jude Osborn
Jude Osborn

Reputation: 1798

There are a couple of solutions that bridge the gap between Cordova/Phonegap and Cast native functionality, providing a JavaScript API layer over the native libraries. Here's one example. You'll either need to use a plug-in like this (if you can get it to work -- there's pretty much no documentation) or write your own plug-ins using Java and Objective-C that essentially relay Chromecast functionality to Cordova.

Upvotes: 0

Ali Naddaf
Ali Naddaf

Reputation: 19034

I haven't worked with Cordova much, but my limited understanding is that they have a native shell/container. Before I get into details, I would say that using native clients makes your life much easier. With that said, what you can potentially do is the following:

  • Add Cast capabilities through the native shell.
  • Manage the cast related states in that native container
  • Write a good amount of code in both the native shell and the javascript side of your app to provide bi-directional communication bridge (apis) between these two pieces. For example the native shell starts discovery of devices and as it finds devices, it keeps a list of them and a the same time informs (using the abovementioned bridge/apis) the web component that a new device was discovered and the web component populates its own list so that when user clicks on an appropriate button in the web component, it shows a list. Similarly, when user selects an item, the web component should call an api on the native part to tell t that a route is selected, etc.

As you can see, you need to duplicate a lot of logic and keep the two worlds in sync. Is it doable? I believe so, but it is a costly activity. The implementation of native part is clearly platform dependent.

Upvotes: 1

Related Questions