RTCMultiConnection Demos cordva for IOS - ios

We integrated RTCMultiConnection Demos cordva code in iOS app and also add iOS native code into it.
need to confirm one thing that how it will be linked with our web code i.e if i will call from my IOS app then how it will get connected within my website . Please confirm if possible and how.
Thanks in Advance plus Happy New Year

Your cordova app sets socketURL:
connection.socketURL = 'https://domain.com:9001/';
Your cordova app has a file named as loadRTCMultiConnection.js. This file MUST be using same RTCMultiConnection distribution as the your web page.
Conclusion:
Your cordova app MUST set socketURL parameter
Your cordova app MUST be using same RTCMultiConnection.js
Explanation:
socketURL is used to access your socket.io server. Both cordova app and web-browsers are using same socket.io server.
Updated at Jan 03, 2017
To use Firebase in the RTCMultiConnection-cordova-apps:
Open index.html and replace socket.io.js with Firebase.js
Add this script in the same index.html file: <script src="js/globals.js"></script>
Add this script in the same HTML file: <script src="js/FirebaseConnection.js"></script>
Opne index.js and add this line: connection.setCustomSocketHandler(FirebaseConnection);
As well as this line: connection.firebase = 'webrtc-experiment';
To recap it:
<!-- index.html file -->
<script src="js/Firebase.js"></script>
<script src="js/globals.js"></script>
<script src="js/FirebaseConnection.js"></script>
and:
// index.js
var connection = new RTCMultiConnection();
connection.setCustomSocketHandler(FirebaseConnection);
connection.firebase = 'webrtc-experiment';
PS. You may need to modify config.xml to enable websocket or XHR_polling requests from firebase.com. Simply replace rtcmulticonnection.herokuapp.com with firebase.com. E.g.
<?xml version='1.0' encoding='utf-8'?>
<widget>
<platform name="android">
<allow-navigation href="https://firebase.com/*" />
<allow-intent href="https://firebase.com/*" />
<access origin="https://firebase.com" />
</platform>
</widget>

Related

How to implement a native WKURLSchemeHandler in cordova-ios 6.1.0

I am working on a cordova ios (6.1.0) project and i want to implement a native WKURLSchemeHandler
to intercept the custom scheme handling to solve my cors problems.
In detail I want to do something like: https://medium.com/#kumarreddy_b/custom-scheme-handling-in-uiwebview-wkwebview-bbeb2f3f6cc1
Till iOS 11, we do not have any system APIs to intercept events from WKWebView.In iOS 11 we got a new API called WKURLSchemeHandler for WKWebView to make our life simpler.
It means that if you want to handle some request on your own, then just define the custom scheme and set it to the WKWebViewConfiguration.
My custom scheme is app://myapp but i need to implement a WKURLSchemeHandler and register it to WKWebViewConfiguration.
Is there any way to implement native ios code on cordova?
You don't need to implement the SchemeHandler, its already in cordova-ios. Just put this scheme in your config.xml:
<platform name="ios">
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
....
</platform>
(and you might need to also set the iosExtraFilesystems and iosPersistentFileLocations prefs)
and in your JS code get the actual URL from WkWebKit, like for e.g. cordova.file.DataDirectory :
url = window.WkWebView.convertFilePath( cordova.file.dataDirectory ) + subPath;
window.open( url );

Cordova on iOS - AJAX call fails with {"readyState":"0", "responseText":"", "status":0,"statusText":"error"}

I updated cordova yesterday and added the iOS platform (cordova-ios#^6.1.0). I am trying to make an AJAX call via the XCODE simulator and it is failing with the following output:
{"readyState":"0", "responseText":"", "status":0,"statusText":"error"}
I installed cordova-plugin-whitelist plugin and added the following lines to config.xml:
<access origin="http://*" />
<access origin="https://*" />
<allow-navigation href="*" />
I have also added the following meta tag to the page:
Any help would be greatly appreciated!
Turns out the issue was with the server being called, a PHP API.
Adding the following allowed the AJAX request to succeed:
<?php
header("Access-Control-Allow-Origin: *");
?>

PhoneGap Build In App Browser not being loaded

I have a phonegap application that is working perfectly through the local server on the phonegap development iOS app.
Specifically, a call to
var ref = cordova.InAppBrowser.open('https://subdomain.domain.com', '_blank', 'location=no');
works fine in the dev app, however when pushed to phonegap build and accessed via the app installed via testflight, using Hydration to update easily, the button is entirely unresponsive.
I have a feeling that none of the plugins are being loaded, as the status bar is malfunctioning as well.
Here is the relevant part of the config.xml file:
<plugin name="cordova-plugin-inappbrowser" spec="~1.7.0" />
<plugin name="cordova-plugin-statusbar" />
<plugin name="cordova-plugin-whitelist" spec="1.3.1" />
I know the insecurity of this, however, changing to the url i am trying to access does not change anything:
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<allow-intent href="*" />
</platform>
The button in question:
<span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> OR SIGN UP
The javascript relating to this button:
document.addEventListener("deviceready", function(){
deviceReadyDependantFunctions();
initializeApplication();
});
function deviceReadyDependantFunctions(){
alert('initialised!');
$('#signUpButton').unbind().click(function(){
console.log('here');
var ref = cordova.InAppBrowser.open('https://subdomain.domain.com?some=variable', '_blank', 'location=no');
ref.addEventListener('loadstart', function(event) { alert(event.url); });
console.log(ref);
});
}
Obviously, there's a bunch of debugging in there....
The "initialised" alert fires in all environments.
The event.url alert fires in the dev app but not in the test flight, hydrated application.
I have been trying everything I can find to rectify this... The only solution I have found is to use a simple href="theUrl.com" and let the system browser load it. Which is not a solution at all... I need to load the url in the app. It's a sign up page and is essential that it can be accessed from the app.
Things I have tried:
Every permeation of whitelisting, although there are varying docs saying that in app browser is/isn't affected by the whitelist plugin.
Using a different version of phonegap (<preference name="phonegap-version" value="cli-6.5.0" />) to no avail.
Checked that the plugins are present in the phonegap build "plugins" tab. They are.
Tried replacing the reference to cordova.js with phonegap.js. This didn't work at all.
The order of loading js files (the above call to inappbrowser is in a seperate js file). No difference.
What am I doing wrong?!
Or is there something weird with the TestFlight/Hydrated Application combination?
You can see the ridiculous commits I have made, as well as the full codebase here:
https://github.com/andycharrington/yfa/commits/master
Any advice would be massively appreciated.
Thank you.
Recompiling the unchanged code with Phone Gap Build this morning seemed to magically fix it. Don't you just love it when that happens? :)

ionic $cordovaGeolocation always requests permission for location access

I am running ionic and the ngCordova geolocation wrapper.
Here is a snippet from a controller using the plugin:
$ionicPlatform.ready(function () {
$cordovaGeolocation
.getCurrentPosition({timeout: 10000, enableHighAccuracy: false})
.then(permissionGranted)
.catch(permissionNotGranted)
.then(loadGmap)
.catch(handleGmapLoadError);
});
I run my app using:
ionic run ios --device
As the app comes up, I am asked permission to access the location of the phone as expected. I acknowledge it and my controller loads my location in google maps. I see the permission set in my ios settings reflect the setting made. when I open the app the second time, it asks again. This was unexpected behavior.
Most apps don't ask again and again. Has any one else seen this behavior and know what I should do?
you can try to add the permission in the config file (app/platforms/android/res/xml/config.xml)
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>
and in the(app/platforms/android/AndroidManifest.xml)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

display iframes ios using phonegap

Im trying to use an iframe using phonegap for ios, this is the code that I'm using, in android works fine but not in ios, any idea how to display the iframe?
<iframe src="https://www.google.com/" style="border:0px #FFFFFF none;" name="myiFrame" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="70%" width="100%"></iframe>
Did you set
<access origin="*" />
in config.xml file?
Also maybe you have to set
OpenAllWhitelistURLsInWebView: YES
ExternalHosts: *
in Cordova.plist file.

Resources