Vivo
Vivo

Reputation: 768

How do I implement WebRTC in Hybrid iOS app?

I have a webpage that uses WebRTC for communication. As there is web interface I don't intend to develop a native application and so I have decided to load the web page in web view But,iOS WebKit does not support WebRTC APIs completely but Android webkit supports WebRTC API completely so I am able to load the page without any problem.

Is there any plugin available sort of like the one available in desktop browsers to achieve this ? if it is there then how to integrate the plugin with webivew. Is there any other way I can achieve this ?

Advance thanks for any help.

Upvotes: 1

Views: 918

Answers (2)

Dr. Alex Gouaillard
Dr. Alex Gouaillard

Reputation: 2128

  1. There is no plugin or any way to extend iOS webview to support webRTC.You have to wait for apple to provide it.
  2. One way to support webRTC on iOS is to use native stacks (like openWebrtc cited in another answer, or webrtc.org) in a native app.
  3. in your case, since you want to reuse your web app, you could use a framework for hybrid app, like cordova, in which case you have a cordova plugin, open source and free which implements webrtc for you: https://github.com/eface2face/cordova-plugin-iosrtc

Upvotes: 1

Durai Amuthan.H
Durai Amuthan.H

Reputation: 32270

Try OpenWebRTC they have already built this and as it is Opensource you can use this for your project as well.

In the AppDelegate we need to initialise OpenWebRTC:

@implementation SimpleDemoAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [OpenWebRTCViewController initOpenWebRTC];
    return YES;
}

@end

Initialising the OpenWebRTC WebView in the view controller

   self.browserView = [[OpenWebRTCWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:self.browserView];

Loading the page is as simple as

    - (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadRequestWithURL:@"http://demo.openwebrtc.io"];
}

They have supported all the unsupported WebRTC APIs natively.

Here is the link that explains on how to go about implementing the OpenWebRTC in iOS Project step by step.

There is a web browser called Bowser has been built on top of OpenWebRTC framework. So you can Open any webrtc supported web apps in the Bowser and it'll work because the unsupported APIs are supported natively using OpenWebRTC framework.

It's not only free app but also OpenSource Project and it has been hosted in Github.You can check the source code on how they have implemented.

You can use this as a reference app for developing your project

Upvotes: 1

Related Questions