I'm building a mobile application for iOS using Meteor and Cordova. I'm having trouble configuring the screen correctly when an input field is clicked on to enter information. The screen does not focus in on the input field until after something is typed on the keyboard, similar to this video: https://github.com/cjpearson/cordova-plugin-keyboard/issues/62
However, in addition to this issue, clicking in the input field renders the constraints all out of whack. (Closing the keyboard makes everything fine again)
Currently I am using cordova-plugin-keyboard. I have unsuccessfully tried cordova-plugin-ionic-keyboard and ionic-plugins-keyboard. In addition to the plugin I'm using, I also have these lines of code, in accordance with this suggestion:
document.addEventListener('deviceready', function() {
Keyboard.shrinkView(true)
window.addEventListener('keyboardDidShow', function () {
document.activeElement.scrollIntoView()
})
})
Any help at all would be greatly appreciated! This issue has been plaguing me for quite a while.
You may try the following - this worked for me.
run meteor add cordova:cordova-plugin-keyboard#1.2.0 command
check cordova-plugins containing this cordova-plugin-keyboard#1.2.0
include App.setPreference('KeyboardShrinksView', true); in Mobile-config
run meteor reset
run meteor run ios-device --port 4000 --verbose
check config.xml containing this
< preference name="KeyboardShrinksView" value="true"/>
Do not manually edit the /.meteor/local/cordova-build/config.xml file,
as it will be regenerated at every meteor run ios/android or meteor
build, hence you will lose all your modifications.
https://riptutorial.com/meteor/example/16152/configure-your-cordova-project--config-xml-
https://docs.meteor.com/api/mobile-config.html
let me know if this is working on your side too.
I'm using Intel XDK and Cordova to create a simple app. I am currently trying to lock the screen orientation in 'portrait' mode.
I tried:
Setting the orientation in 'Build settings' in Intel XDK
Setting the orientation in the config file (intelxdk.config.additions.xml) as such: <preference name="orientation" value="portrait" />
The Cordova Core Plugin: https://github.com/apache/cordova-plugin-screen-orientation
So far nothing has worked. I think the plugin should work, but I am afraid I am implementing it in the wrong way. I started with this (it's the already existing app.js file which is linked in the HTML head section, I just added 1 line of code):
document.addEventListener("app.Ready", onAppReady, false) ;
function onAppReady() {
if( navigator.splashscreen && navigator.splashscreen.hide ) {
navigator.splashscreen.hide() ;
screen.lockOrientation('portrait');
}
}
//window.screen.lockOrientation('portrait'); //Makes no difference
Should I place this code somewhere else? Other functions that I place in this location do work...
Also, when I try to simulate the app, I get this message.
Even if I do something like screen.lockOrientation('portrait', onAppReady, false);
Can anyone help me? Thank you!
EDIT: So I just found out that a simple console.log(screen.orientation) or console.log(window.screen.orientation) already doesn't work. It logs "undefined". I added the plugin via the XDK Projects menu (other plugins added this way are working fine). Does anyone have any suggestions on how I can make this plugin work?
I don't know about the intel-xdk, but in Cordova, you can edit config.xml in the project root to include the <preference name="orientation" value="portrait" /> entry there, directly inside the widget element. If there is also a config.xml in your project, I'd recommend experimenting with putting this value there too.
How do you change the string on the alert saying:
(Appname/whatever it is) would like to use your current location
Of course, I only want to change the appname part. Because when you use the PhoneGap framework, the string is very ugly, something like this:
/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html
Someone having an idea?
You need to do the geolocation after the device is ready. The following Jquery code, for example, will geolocate without that nasty alert:
$(function(){
document.addEventListener("deviceready", onDeviceReady, false);
})
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
// your callback here
}
function onError(error) {
// your callback here
}
On phonegap 3.0 the answer by Pius Uzamere needs to be followed AND the plugin installed.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
otherwise you will get the double permission request.
I just followed the documentation and solved it.
Open the terminal and cd to your project and enter following command.
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
Also add this in your config.xml
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
It will solve this issue. :)
Source: http://docs.phonegap.com/en/3.0.0/cordova_geolocation_geolocation.md.html#The%20Command-line%0AInterface
Although this question is much older, I found similar questions here and here.
For my resolution, I had to add NSLocationWhenInUseUsageDescription to the .plist file. However, I suppose since my geolocation plugin was out of date, I had to update it first. Then I had to remove/add the Cordova iOS platform. Finally, I added NSLocationWhenInUseUsageDescription to the .plist file.
First, remove/add the geolocation plugin:
cordova plugin rm org.apache.cordova.geolocation
cordova plugin add org.apache.cordova.geolocation
Second, remove/add the iOS platform:
cordova platform rm ios
cordova platform add ios
Last, add NSLocationWhenInUseUsageDescription to the .plist. Open /platforms/ios/{project}/{project}-Info.plist and add the following:
<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>
See this iOS Developer Library link for detailed information regarding NSLocationWhenInUseUsageDescription versus NSLocationAlwaysUsageDescription versus NSLocationUsageDescription.
Finally fixed the issue.
IN the index.html just move your cordova.js up
<script src="cordova.js"></script>
as the first js file to be included (especially make sure it is above maps include js). This will make sure that the prompt shows only once.
No other codejs or ondeviceready is needed.
After looking for solution i've founded, just add a variable when you add the plugin location like this line
cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="your usage message"
None of the above answers worked for me. My location request was already firing on deviceready. Adding the following to config.xml fixed the issue:
<gap:plugin name="org.apache.cordova.core.geolocation" />
To solve the issue I have to run cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git which adds (automatically) to the config.xml the following:
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
To get things working I have to put also this lines into the config.xml:
<plugins>
<plugin name="Device" value="CDVDevice" />
<plugin name="Logger" value="CDVLogger" />
<plugin name="Compass" value="CDVLocation" />
<plugin name="NetworkStatus" value="CDVConnection" />
<plugin name="Debug Console" value="CDVDebugConsole" />
<plugin name="Geolocation" value="CDVLocation" />
<plugin name="SplashScreen" value="CDVSplashScreen" />
<plugin name="Battery" value="CDVBattery" />
<plugin name="Globalization" value="CDVGlobalization" />
</plugins>
Hope it could be helpful.
After making sure my geolocation request was called after the device was ready, making sure the geolocation plugin is correctly installed and configured, I was still receiving the unsightly popup.
I resolved it by moving and referencing my cordova.js file and cordova_plugins.js files into the root directory of my application (they were originally in a subfolder), so the path to cordova.js would be:
<script src="cordova.js"></script>
I feel this should be included in the documentation (maybe it is, but I haven't managed to find it)
Just by including "cordova.js" file in your html file where you are accessing this location will resolve this issue. NOTHING FANCY REQUIRED.
1) modify Location.m in PhoneGapLib project. replace all references of
navigator.geolocation with navigator_geo
2) Copy phonegap.js to phonegap2.js and put in root of app. I have now
learned that every time I build my application and load it onto device
or simulator, the phonegap.js file is being regenerated. OK. Well I
need to modify it so lets just use another one and deal with the
hassles of upgrading in the future.
3) Modify the line (in phonegap2.js) that creates the constructor for
the navigator.geolocation on 626 to be ... if (typeof navigator._geo
== "undefined") navigator._geo = new Geolocation();
4) Now in your HTML whenever you want to use the PHONEGAP GPS stuff,
you can reference it with navigator._geo.getCurrentPosition or similar
5) Enjoy the ONE, and CLEAN, location alert permission without
revealing to your users your intelligence to use PhoneGap and build an
app with HTML/JS.
* CAVEAT AND PLEASE HELP! *
If I run the watchPosition function, I will get the first location
update with all sorts of stats. There after, It will always report an
error. I assume this sucks for this 30 second time of getting accurate
GPS on these things?
http://groups.google.com/group/phonegap/browse_thread/thread/8067c2037816a9ad
I followed all the instructions and it still failed. In the end I played around with the PhoneGap demo and found the final solution:
Move all the js files and html files into the same folder (not even sub-folder). Congratulations! Problem solved, no permission alert any more : )
BTW, You'd better use a " setTimeout(function(){utility.getGeoData();},1000);" I found "document.addEventListener("deviceready", utility.getGeoData(), false);" not work for me.
Hope that helps when you find no solution above : )
Good luck!
Since I was struggling for days now with the same problem and finally found the solution, I decided to share it with anyone who still was not able to fix it.
The solution is simple: The geolocation plugin was missing in the plugins directory within the www directory, even though I added the plugin via the phonegap command line interface AND the plugin files were in the /Plugins directory. So you only have to copy the missing files into /www/plugins and you are done. Just simple as that.
If anyone needs the missing files: http://d.pr/f/xqhq
btw: i am using cordova 3.2.0.
I hope this works for you as well!
Phoengap/Cordova version 3.5 here.
Similar to Manuel's answer above but this time the plugin does not install in the platforms/ios/[appname]/Plugins folder.
The fix for me was to just manually create a new folder for the plugin in the ../platforms/ios/[appname]/Plugins folder > then rename it to org.apache.cordova.geolocation > then copy the .h and .m files of the plugin into it.
You can find the .m and .h files for the geoLocation plugin in the [root]/plugins/org.apache.cordova.geolocation/src/ios directory.
Got this error (and a lot of others) after upgrading Cordova from 3.6 to 4.3.
I think there is some fails in the upgrade process and the only working solution for me was cordova platform rm ios then cordova platform add ios
/!\ You will lost all your ios project settings and you need to reupload splash and icons.
In my case, I am using Cordova/Ionic and have experienced the same problem. That's because of the code before device is ready. I have simply wrapped the code with document.addEventListener on "deviceready". For example:
document.addEventListener("deviceready", function () {
$cordovaGeolocation.getCurrentPosition(options).then(function(position){
...your code here...
});
});
Then the additional message does not appear.
I'm late to the party here, but will answer the question for reference.
The answer is to use the geolocation functions found in phonegap.js which is included with Phonegap. You will be able to find such instructions on the Phonegap site at http://www.phonegap.com.
If you use navigator.geolocation, you are using the default Safari geolocation system. This happens as PhoneGap works by running your pages effectively in a Safari instance. If you include phonegap.js into your site, you can use a separate geolocation method exposed by PhoneGap's Objective-C code, which will present the behaviour seen in other apps where it asks for permission from [your app name].
"Move all the js files and html files into the same folder (not even sub-folder). Congratulations! Problem solved, no permission alert any more : )" Like Caleb says works for me, well only moving the cordova.js file to the root and adding the plugin to config.xml
What is the Bundle display name of your project?
Try changing manually from the default value ${PRODUCT_NAME} and see..
That Permission to use location alert picks your bundle display name only!!
Team,
I am working on a project which is on Titanium, I am facing one small issues which i cannot find the solution, The issue is
In Index.xml file i am writing code for Tabbar, Writing the click action the tag but in iOS that method is not calling, Where as in Android it is working fine, Dont know whats wrong, Below is the code i wrote.
<Tab id="tab4" title="Coverage" icon="/images/Coverage_tab_n.png" onClick="displayCoverage" class="bcPurple_iOS">
<Window id="win4" title="Coverage" top="20" bottom="20" class="bcPurple_iOS">
</Window>
</Tab>
The onClick action code i am writing in the index.js file which is deault,Am i doing any wrong.
This is a feature request in Titanium TIMOB-6499 It was requested to be added in Android and was but hasn't been added in iOS yet.
Work around could be to use onFocus which works but might not be exactly what you want as it runs when the tabgroup opens. To avoid that, you could set a variable to stop it running on the first load I suppose.
If you're into compiling from source, there is a quick fix from someone in comment thread in the link above which may or may not work.
The feature request has been open since Dec 2011 and is marked as low priority.
Our Umbraco site was writing out its site structure to its XML config file for most of the project but recently it has stopped doing this and we don't know why. We haven't done anything new or unusual and we didn't notice it straight away so we are not to sure if there was a change that actually triggered this.
I have checked the premissions on the folder and i am sure that it has premissions to write.
I don't know what else to look for. Does anybody have any suggestions for what i should be looking for or experience with this happening?
The best place to start look at this problem is Umbraco Database.you can see a table name dbo.umbracoLog .In this table all activities like writing to xml config files will be recorded.If an error has occurred you will definitely get some info from there which will lead you to finding out the real cause
Well i figured it out after binary sorting my way through the revision history there was a change in the app config:
<add key="umbracoContentXMLUseLocalTemp" value="true" />
setting this to false made this reappear im my App_Data folder. I assume that it was actually appearing in the temp folder when this was set to true. If somebody wants to edit this answer with more specifics it would be interesting to know what this setting actually does.