Install plugin cordova - javascript

I have to develop an app that check if gps is enabled or disabled. If gps is disabled, I have to send users on device's settings.
I find this plugin to do that.
So, I installed the plugin using node.js using command line (cordova plugin add com.dataforpeople.plugins.gpssettings).
I use this code in javascript file to go to device's settings :
var gpsDetect = cordova.require('cordova/plugin/gpsDetectionPlugin');
phonegapReady().then(function () {
gpsDetect.checkGPS(onSuccess, onError);
});
but in the logcat i have this error:
07-22 15:36:59.555: E/Web Console(2230): Uncaught module
cordova/plugin/gpsDetectionPlugin not found at
file:///android_asset/www/cordova.js:59
Anyone know how can I fix this problem?

Related

How can I open my node.js program in chrome? - VS Code

I'm new to node.js, and VS Code. I'm watching this tutorial, and the issue is that in the video, he runs his server. I can do this fine, but, when he opens his browser and types http://localhost:8888, he can connect to the server like he is a client. When I do this, the program Emit(I think that is what its called) opens and has an error - Error: ENOENT: no such file or directory, open 'h:\Microsoft VS Code\bin\index.html' at Error (native). In the beginning of the tutorial, he went to edit configurations and entered the local host url into some text box and changed other settings. Although, he is using IntelliJ, and I'm using VS Code. How can I make it so I can enter the url and run as a client.
[EDIT]: When I try to start without debugging, I get the options select enviornment - Chrome or Node.js. Also, I went to the terminal and typed node app(file name is App.js), and I get the error in the terminal - module.js: 471. throw err. Error: cannot find module at C:Users\Name\App
Thank you.

Cordova web intent Plugin Not working for version 7.0.1

I am using Cordova version 7.0.1,I want to use webintent and when i am trying to install like this
cordova plugin add https://github.com/Initsogar/cordova-webintent.git
i am getting this error
I am trying to recieve the url from the other apps to my cordova app and the code i am following is this one.
window.plugins.webintent.getExtra(window.plugins.webintent.EXTRA_TEXT, function (url) {
alert(url);
console.log("coming");
}, function() { //Fail
alert ("error");
});
when i am executing i am getting this error
Error: exec proxy not found for :: WebIntent :: getExtra
PS: I know that URL is not working,Is there any other way to install Web Intent
That repository is no longer available.
I could successfully get the plugin from https://github.com/cordova-misc/cordova-webintent

Unable to launch Appcelerator IDE?

Followed Steps provided by platform.appcelerator.com :
Account Created
Download Appcelerator Studio IDE
Installed Sucessfully
Launching by providing Username and Password
Error Occurred and unable to lanunch , Here is screenshot:
Kindly help to solve this issue . Any help is highy appreciated.
The problem is - Appcelerator Studio is unable to install latest appc CLI due to proxy/network configuration issues.
To identify the root cause.
Open a terminal and run the below command.
appc use latest
Is it the same error which you've reported? If yes, verify proxy configuration
appc config get proxyServer
Does it show any configured proxy? If yes, and it was set unintentionally, you can remove that by running the below command.
appc config set proxyServer
This will nullify your proxy configuration.
If there is no proxy configured, still you are facing the issue. Then, your network firewall is not allowing to access Appcelerator Software Update site.
Contact your network admin to unblock it.

How do I use cordova inappbrowser to open links in Ionic/Angular hybrid app

I am working on a hybrid mobile app using Ionic Framework and AngularJS. I am using Ionic Creator & Ionic Lab. In my app, I have several buttons that link to external resources (webpages, mailto: links, pdf files etc). The links work fine when I test them within the browser (Ionic Lab). However, when I test the app in an Android virtual device or an actual device, none of the links are working.
I found a question where someone had a similar issue:
/questions/33627061/ionic-simple-href-not-working-on-android-device
I tried Implementing all the proposed solutions from adding to config.xml:
<allow-navigation href="*" />
Installing cordova inappbrowser plugin via:
$sudo cordova plugin add cordova-plugin-inappbrowser
I tried using ng-click="some_function()" instead of href, then defining the function in my controller.
The OP on that question finally resolved his issue by commenting out/uncommenting from index.html:
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
Looking at my browser console logs there was a 404 not found for cordova.js, so I manually added it to www/ from the platform_www/ directory for android, as well as cordova_plugins.js
However after trying all this, the links are still not working. In my consol logs I now get an error saying:
GET http://localhost:8100/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js 404 (Not Found)
Uncaught Error: Module cordova-plugin-inappbrowser.inappbrowser does not exist. http://localhost:8100/cordova.js Line: 1421
But the thing is inappbrowser.js is in that folder!
Please help! I'm at wits end and have no idea what to do next. I have uploaded the sample code I'm working with on github:
https://github.com/chmod-777/link-test
Software versions:
Linux mint 17.1
node v0.12.2
npm 2.7.4
cordova 6.2.0
ionic 1.7.14
For starters, try changing the way you're calling the open method in your controller code to this:
.controller('pageCtrl', function($scope, $window, $cordovaInAppBrowser) {
$scope.open_google = function() {
$cordovaInAppBrowser.open('https://www.yahoo.com/', '_system', 'clearcache=yes');
// I also tried this
//$window.open('https://www.msn.com/', '_system', 'location=yes');
// and this
//window.open('https://www.netflix.com/', '_system', 'location=yes');
}
})
I have used the inappBrowser plugin with Jquery mobile.It worked fine.
ref=null;
var url= accRestService.someURL;
if( device.platform === "Android"){
ref =cordova.InAppBrowser.open(url, "_blank",'location=no,clearcache=yes,hardwareback=no,zoom=no');
}else{
ref =cordova.InAppBrowser.open(url, "_blank",'location=no,clearcache=yes,closebuttoncaption=Go back to App,toolbar=yes,presentationstyle=formsheet');
}
ref.addEventListener('loadstart',onBrowserLoadStart);
ref.addEventListener('loadstop',onBrowserLoadStop);
ref.addEventListener('loaderror', onBrowserError);
ref.addEventListener('exit', onBrowserClose);
First, make sure that you have installed the cordova plugin "inappbrowser"
cordova plugin add cordova-plugin-inappbrowser
(see https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/index.html)
Then, you can use for example :
try {
var uri = "http://some-example.com";
cordova.InAppBrowser.open(uri, '_system');
} catch(e) {
window.open(uri, '_blank');
}
the catch block will be used as a fallback when testing the app in a browser.

How to debug a cordova plugin with your phone?

I use Weinre to get a console from my phone. But on Javascript errors with plugins (contacts, geolocalisation etc...) I get nothing....
I don't know how to push on the console every javascript errors.
How to easily debug your javascript which use a plugin present only on your device ?
Thank you.
You can use the Console Plugin to debug your code in iOS, android, windows phone, etc.
Install the plugin using: $ cordova plugin add org.apache.cordova.console
Then its as simple as using console.log(...); in your javascript files.
If you want to log your geolocation you can do:
var onSuccess = function(position) {
console.log(position.coords.latitude);
console.log(position.coords.longitude);
};
var onError = function(err) {
console.log(error.code);
console.log(error.message);
};
navigator.geolocation.getCurrentPosition(onSuccess, onError);
Then, when you build your app, and emulate, look for this log file in your project:
.../platforms/ios/cordova/console.log

Categories

Resources