I have a phongap app almost ready to be released,
The app gets data from a database (AJAX), shows the users location on google maps and stores a few strings in the users localstorage.
I built my app useing phonegap build and it all works great.
My problem is when I download the APK to my device I am asked for all posible permissions.
I unchecked all unwanted features in the WMAppManifest, and my config.xml shows:
<features>
<feature name="Device">
<param name="wp-package" value="Device" onload="false"/>
<param name="android-package" value="Device" />
</feature>
<feature name="NetworkStatus">
<param name="wp-package" value="NetworkStatus"/>
<param name="android-package" value="NetworkStatus" /></feature>
I'm pretty sure my problem is in the config file but what is it?
Thanks in advance.
You can set the individual permissions in your apps config.xml.
First, disable all permissions.
<preference name="permissions" value="none" />
After that, you can enable the required permissions one by one.
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/camera" />
<feature name="http://api.phonegap.com/1.0/notification" />
<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/contacts" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/battery" />
<feature name="http://api.phonegap.com/1.0/device" />
Just insert the feature(s) you need – the others can/should be left out.
Source: PhoneGap Build Documentation (Features section)
Related
I have an issue I have been trying to solve, none of the solutions online I have seen have helped either.
Very simple, so you think the solution would be as well.
On the Android platform for Cordova build I am using the StatusBar plugin which is set in the config.xml to preference and DISPLAY it...Yes, I am trying to get it to display in the app and not hide. It seems to be hidden every time the app runs.
In my InAppBrowser option string, I also set fullscreen=no so that that won't affect it either.
Running the app in the simulator and on-device both hide it still. Would someone possibly know a solution to FORCE the status bar to show and if not, what are the causes of this?
onDeviceReady: function() {
StatusBar.overlaysWebView(true);
//InAppBrowser Init
var options = "location=no,fullscreen=no,zoom=no"
Browser = cordova.InAppBrowser.open('http://www.app.example', '_self', options);
The StatusBar plugin is also being imported correctly and can be seen here, this was done via plugman:
Here is my Config.xml file for better supporting information:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.pulse_co" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
<param name="onload" value="true" />
</feature>
<feature name="OneSignalPush">
<param name="android-package" value="com.plugin.gcm.OneSignalPush" />
</feature>
<name>Pulse</name>
<description>
Add Pulse App Description Here
</description>
<author email="email#test.com" href="https://support.example.com">
Team
</author>
<content src="index.html" />
<access origin="https://root.domain.co*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="market:*" />
<preference name="loglevel" value="DEBUG" />
<preference name="StatusBarOverlaysWebView" value="true" />
<feature name="StatusBar">
<param name="android-package" value="org.apache.cordova.statusbar.StatusBar" />
<param name="onload" value="true" />
</feature>
Install statusbar plugin
cordova plugin add cordova-plugin-statusbar
If that still doesn't work, try calling show after deviceready event
StatusBar.show();
Remove
StatusBar.overlaysWebView(true);
Or set it to false
Also remove
<preference name="StatusBarOverlaysWebView" value="true" />
Or set it to false
OverlaysWebview males the statusbar transparent
The options only have effect on InAppBrowser if you use '_blank'.
'_self' = open in Cordova window
'_blank' = open in InAppBrowser window
'_system' = open in system browser
The accepted answer didn't work for me
For anyone still facing this,
according to Cordova plugin page
fullscreen: Sets whether the InappBrowser WebView is displayed
fullscreen or not. In fullscreen mode, the status bar is hidden.
Default value is yes.
So, in order to keep status bar visible, pass fullscreen: "no" in options
let browser = this.inAppBrowser.create(
"https://github.com"
"_target",
{ zoom: "no", location: "no", fullscreen: "no" }
);
I am writing a Cordova plugin for Android, and it is not registering a JavaScript object to window and I would like to know why.
In the plugin's plugin.xml, I am using <js-module> to register the js object to window object:
<platform name="android">
<js-module src="www/Loading.js" name="loader">
<clobbers target="loader" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Loading">
<param name="android-package" value="org.apache.cordova.loader.Loading" />
<param name="onload" value="true" />
</feature>
</config-file>
...
</platform>
The plugin compiles, but when I do window.loader in Chrome debugger, it is undefined. I tried changing the value of target in <clobbers> to window.loader to no avail.
www/Loading.js file is exporting a JavaScript object using module.exports:
function Loading() {
...
}
module.exports = new Loading();
Any suggestions?
Resolved. This is a very specific case for my app. I am copying everything from the sandboxed environment to an internal path and booting the app from the internal path. Turns out the app was not copying the www/Loader.js file.
I'm currently building an Angular app for Android / iOs (with Cordova).
I'm encountering an issue : the app have to work when the device is offline. On iOs, when I switch the device offline, it's ok.
On Android (real device on 4.1), if I put the device offline and come back to the app, it alerts me that the app have crashed.
I dont know where I can find any log about what happens, any help would be great :)
Here's my config.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<widget id="fr.menutab.app" version="0.0.1">
<name>App title</name>
<description>Not yet</description>
<author email="dev#callback.apache.org" href="http://cordova.io">
Author
</author>
<!-- PLUGINS -->
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
<param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
<feature name="Console">
<param name="ios-package" value="CDVConsole" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
<!-- PREFERENCES -->
<preference name="target-device" value="universal" />
<preference name="Orientation" value="landscape" />
<preference name="Fullscreen" value="true" />
<preference name="phonegap-version" value="3.3.0" />
<!-- ACCESS CONTROL -->
<access origin="*" />
</widget>
Tell me if you need to see more code :)
I was having this same problem. Found this article on problems updating to cordova 3.5.0.
http://excellencemagentoblog.com/cordova-3-5-0-update-troubleshooting-android
The fix that worked for me is at the bottom of the article:
cordova plugin remove org.apache.cordova.network-information
cordova plugin add https://github.com/apache/cordova-plugin-network-information
You can try with "Offline" Event.
The event fires when an application goes offline, and the device is not connected to the Internet.
document.addEventListener("offline", yourCallbackFunction, false);
The offline event fires when a previously connected device loses a network connection so that an application can no longer access the Internet. It relies on the same information as the Connection API, and fires when the value of connection.type becomes NONE.
Applications typically should use document.addEventListener to attach an event listener once the deviceready event fires.
Example :
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
document.addEventListener("offline", onOffline, false);
}
// Handle the offline event
//
function onOffline() {
}
</script>
Source Link : http://docs.phonegap.com/en/3.1.0/cordova_events_events.md.html#offline
Hope this helps.
Working on Windows with Phonegap 3.0, Android platform, debugging in Eclipse.
I was able to get my old app to compile but I have encountered a new problem when I try to use a feature that is now a plugin.
I have added all the plugins I need through the CLI tool and have added the "feature" data to the config.xml file, so I assume that they are available to be called. The permissions are also set in the manifest file.
FileTransfer
I see that the File Transfer API example code has not changed for 3.0, so I left the call the same in my code. So the file will download but then I get an error that makes my app crash
"
D/CordovaLog(12883): file:///android_asset/www/phonegap.js: Line 932 : Uncaught Error: Error calling method on NPObject!
"
I did some searching for this error and there doesn't seem to be a standard solution?
Perhaps there is a new way to call features that are within plugins? Because I can't play an audio file without getting errors as well. The sound file will play but will cause errors.
"
09-01 20:13:17.274: W/PluginManager(13279): THREAD WARNING: exec() call to Media.startPlayingAudio blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
"
I have re-read the media API and there is no mention of a thread pool. I am doing all of my programming in javascript.
Essentially where ever I use a plugin feature the app has major errors. I tried using my record sound feature in my previously working app, and when I call a stop to my recording it throws an error
"
09-01 20:10:04.206: E/AudioPlayer(13279): FAILED renaming /mnt/sdcard/tmprecording.3gp to /sdsub/myapp/Recorded/myRecording.amr
"
I tested the file transfer api again through my file remove function and it also failed
"
09-01 20:16:00.884: W/PluginManager(13279): THREAD WARNING: exec() call to File.remove blocked the main thread for 19ms. Plugin should use CordovaInterface.getThreadPool().
"
it seems like the essential nature of how features work has changed but is not documented anywhere. The API calls seem unchanged from older versions, just how you install the API features is different, but I followed that guide and installed them.
Is there a new API guide that I have missed? because the Phonegap API documentation hasn't changed for how these features are called in 3.0.
Thanks.
my config file
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="File">
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<feature name="Compass">
<param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener" />
</feature>
my Manifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
while you are upgrading your application , the phonegap.jsfile must suppport all the functional script . you can use the suitable version of javascript file like phonegap.0.9.5.js or higher version too . It might be because the phonegap.js didn't contain the necessary function needed by the application . If you see the API they have the phonegap .X.Y.Z.js . so you can try higher one
I am Using PhonegapBuild Not eclipse for build my application.
We are not using any custom plugin. I read the post about plugin but i think it's for custom plugin so i didn't change anything in XML and it gives me error "plugin unsupported: splashscreen" So can any one help me how to get rid of it.
In Config.xml splash plugin line is same as mentioned in docs and it's as below
For Android:
<gap:plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
For IOS:
<gap:plugin name="SplashScreen" value="CDVSplashScreen" />
Please help me..
Screenshot is below
I removed all plugin from my config.xml for Android as well IOS also.Then i successfully upload my Zip file for Build and its Build and Working Fine in Device..
As far as I can tell, you must be confused with the feauture and the plugin
Try using the following for the feauture
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.SplashScreen"/>
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
</feature>
Try using the following for the plugin
<gap:plugin name="cordova-plugin-splashscreen" source="npm" version="2.1.0" />
But I also have a problem with my splashscreen, so it may not be 100% correct. My problem is that my images are not being recognized.