navigator is not working inphonegap - ios

Hello guys I got an issue with navigator in my previous app it was working but now it is not working i tried in many way but couldn't figure out the issue.
phonegap -v is 3.3.0-0.19.6
cordova -v is 3.3.1-0.4.2
for installing plugins i tried below types
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.dialogs
Below is my config.xml file
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.company.multipleScreen" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Hello Cordova</name>
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<name>testing</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<feature name="Camera">
<param name="ios-package" value="CDVCamera" />
</feature>
<feature name="Media">
<param name="ios-package" value="CDVSound" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
<param name="onload" value="true" />
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture" />
</feature>
<feature name="Globalization">
<param name="ios-package" value="CDVGlobalization" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
The code i tried to implement for showing alert is
navigator.notification.alert("Unable to connect to server !");
and my other requirement is camera it is also not working
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
function onSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}

In the current Cordova version 3.4.0 you have to manually install all plugins via cordova plugin add
So in your case, referring to https://github.com/apache/cordova-plugin-dialogs/blob/dev/doc/index.md, you need to do:
cordova plugin add org.apache.cordova.dialogs
I would recommend reading the documentation about plugins:
http://docs.phonegap.com/en/3.4.0/cordova_plugins_pluginapis.md.html#Plugin%20APIs

Issue is fixed by adding
cordova plugin add org.apache.cordova.device
cordova plugin add org.apache.cordova.console

Related

Cordova StatusBar plugin fails randomly

I'm trying to run an iOS Cordova app using the StatusBar plugin (version 2.3.0).
My problem is that the plugin will be loaded randomly and also works just randomly.
Sometimes I get this error on Xcode:
[CDVTimer][statusbar] 5.837023ms
ERROR: Plugin 'StatusBar' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["StatusBar1191468497","StatusBar","_ready",[]]
and sometimes it's just working fine.
My config.xml:
<plugin name="cordova-plugin-statusbar" spec="2.3.0" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" />
<param name="onload" value="true" />
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#445E75" />
<preference name="StatusBarStyle" value="lightcontent" />
I also tried removing the platform and adding it again, removing the ios.json... I always get the same result.
The solution was to call the JavaScript methods of StatusBar.
document.addEventListener("deviceready", function(){
StatusBar.overlaysWebView(false);
Statusbar.backgroundColorByHexString("#445E75");
Statusbar.styleLightContent();
}, false);

org.apache.cordova.facebook.Connect plugin error

I am using org.apache.cordova.facebook.Connect plug-in and I am having this error.
ERROR: Plugin 'org.apache.cordova.facebook.Connect' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"org.apache.cordova.facebook.Connect165525704",
"org.apache.cordova.facebook.Connect",
"init",
[
"app id"
]
]
my cordova version is 3.5.0.
I’ve try to add appname/plugins/plugin.xml to this.
<feature name="FacebookConnectPlugin">
<param name="ios-package" value="FacebookConnectPlugin"/>
<param name="onload" value="true" />
</feature>
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.4.0">
<param name="APP_ID" value="appid" />
<param name="APP_NAME" value="appname" />
</gap:plugin>
<plugin name="FacebookConnectPlugin" value="FacebookConnectPlugin" />
but no luck!! I’ve Change FB.login to facebookConnectPlugin.login but again no luck..
one more thing my application use contacts to send invitations, so in my ios device, settings/privacy/contacts I can see that my application, but in Facebook I can't see my application. I I’ve already gave permission like this.
<feature name="FacebookConnectPlugin">
<param name="ios-package" value="FacebookConnectPlugin" />
<param name="onload" value="true" />
</feature>
<plugin name="FacebookConnectPlugin" value="FacebookConnectPlugin" />
<access origin="https://m.facebook.com" />
<access origin="https://graph.facebook.com" />
<access origin="https://api.facebook.com" />
<access origin="https://*.fbcdn.net" />
<access origin="https://*.akamaihd.net" />
<feature name="Contacts">
<param name="ios-package" value="CDVContacts" />
</feature>
please help.!!!!

Cordova Geolocation API not working IOS 8

Am developing a Jquery mobile application using cordova geolocation api.
Cordova : 3.6.3,
geolocation : cordova plugin add org.apache.cordova.geolocation (latest version),
jQuery Mobile : 1.4.4
Am getting exact current position using following code
navigator.geolocation.getCurrentPosition(drawMap,handleError, {
enableHighAccuracy: true,
maximumAge : 0,
timeout : 60000
});
Problem with watch position, its always trigger Unknown Error. The same code working fine in IOS-6
watchProcess = navigator.geolocation.watchPosition(handleSuccess,
handleError, {
enableHighAccuracy: true,
maximumAge : 0,
timeout : 60000
});
switch(error.code)
{
case error.PERMISSION_DENIED:
alert("User did not share geolocation data");
$(".ajax-loader").hide();
break;
case error.POSITION_UNAVAILABLE:
alert("Could not detect current position");
$(".ajax-loader").hide();
break;
case error.TIMEOUT:
alert("Retrieving position timed out, could not detect your location");
$(".ajax-loader").hide();
break;
default:
alert("Unknown Error"); // Always getting Unknown Error
$(".ajax-loader").hide();
break;
}
Tried adding following code in my platforms/ios/NavSustain/config.xml file but no luck
<gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="false"> <array> <string>Allow GPS</string> </array> </gap:config-file>
My config.xml file is
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.navsustain.navsustain" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value=".25" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<name>NavSustain</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="false"> <array> <string>Allow GPS</string> </array> </gap:config-file>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
<param name="onload" value="true" />
</feature>
</widget>
Your help is much appreciated. Thank you
Finally found the issue. I have update Xcode to latest version Xcode 6. Now its working fine.

StatusBar preferences not working: phonegap version 3.6.3

I have a problem with the StatusBar in iOS. My app ID is 234560, StatusBar version "0.1.4" as suggested (here) and phonegap version 3.6.3. I have granted the permissions (CDVStatusBar) and the preferences (StatusBarOverlaysWebView false, StatusBarBackgroundColor A7A7A7 and StatusBarStyle lightcontent) with no sucess. My bar still appears as if StatusBarOverlaysWebView would be set to true and the background color is also not applied. This is how the relevant preferences are set in my config.xml:
<preference name="phonegap-version" value="3.6.3" />
<preference name="orientation" value="both" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="false" />
<preference name="stay-in-webview" value="true" />
<preference name="show-splash-screen-spinner" value="true" />
<gap:plugin name="org.apache.cordova.statusbar" version="0.1.4" />
<preference name="permissions" value="none" />
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true" />
</feature>
<preference name="StatusBarOverlaysWebView" value="false"/>
<preference name="StatusBarBackgroundColor" value="#A7A7A7"/>
<preference name="StatusBarStyle" value="lightcontent" />
I would love to have any assistance, I have been reading a lot of issues regarding to this topic but non of them were ussing this phonegap version. Thank you in advance!
I had the same problem, then I decided to remove the plugin and then add it again, it worked!!
The github site for the plugin says this which worked for me:
iOS Quirks:
Starting with iOS 11 you must include viewport-fit=cover in your index.html viewport meta tag if you want the status bar to overlay the webview:
<meta name="viewport" content="initial-scale=1, width=device-width, **viewport-fit=cover**">

Phonegap 3.0 Build inAppBrowser listeners not working

I hope someone can help me figure this out. This is my first Phonegap app, so this could be a fairly elementary mistake on my part. I'm specifically trying to get this to work on iOS. Android will wait until another day.
I'm trying to load a page from an external site (which I do control) using the inAppBrowser. After the user leaves the initial page, it should close and return them to the app. The page opens successfully, but I've tried everything I can think of to get it to close and return to the app, but to no avail.
The function using inAppBrowser looks like this:
function open_page() {
var ref = window.open('http://www.mydomain.com/page1.html', '_blank', 'location=yes,enableViewportScale=no');
ref.addEventListener('loadstop', function(event) { if(event.url != "http://www.mydomain.com/page1.html") ref.close(); });
ref.addEventListener('exit', function(event) { alert(event.type); });
}
I am using the cloud-based Phonegap Build, and my config.xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<widget
...
<access origin="*" />
<preference name="phonegap-version" value="3.0.0" />
<preference name="orientation" value="portrait" />
<preference name="fullscreen" value="true" />
<preference name="stay-in-webview" value="true" />
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.device-orientation" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.globalization" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.network-information" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<gap:plugin name="org.apache.cordova.core.geolocation" />
</widget>
Thanks in advance for all help!
Add this to your config file-
<access origin="*" browserOnly="true"/>
For open link in APP browser use following line, which open link in app browser.
And return back to your application when you closed it.
window.open('http://www.' + email, '_blank', 'location=yes');

Resources