Coder Social home page Coder Social logo

cordova-diagnostic-plugin's People

Contributors

adascal avatar ajuanjojjj avatar artlogic avatar ath0mas avatar casperverswijvelt avatar cmgustavo avatar davidgovea avatar dpa99c avatar dukhanov avatar eugenepotapenko avatar fcamblor avatar ghenry22 avatar iodev avatar jackmckew avatar lissonpsantos2 avatar mablack avatar matt-auckland avatar mdailor avatar mread1208 avatar nleclerc avatar noeldemartin avatar peitschie avatar quentinfarizon avatar sebj54 avatar spoxies avatar tushar-bidchat avatar tylerbreau avatar vorlif avatar wangjian2672 avatar wezzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-diagnostic-plugin's Issues

2.3.11 Camera Permissions

2abb480

Removal of Camera permission line prevents apps from requesting access for Camera support.
It only requests Storage. All of the status checks for Camera then return GRANTED but checking the App settings, Camera is not, only Storage.
Specifying 2.3.10 in phonegap fixes issue.

I’m not sure if it’s only my phone, tested on Android 6.0, HTC One M8.

iOS class `CLLocationManager` is responding slow on iOS 9.1

- (void) isLocationEnabled: (CDVInvokedUrlCommand*)command
{
   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
    NSLog(@"Loading Location status...");
    CDVPluginResult* pluginResult;
       if([self isLocationEnabled] && [self isLocationAuthorized]) {
           pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:1];
       }
       else {
           pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:0];
       }
       [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
       dispatch_async(dispatch_get_main_queue(), ^{
       });
   });
}


- (BOOL) isLocationEnabled
{
   if([CLLocationManager locationServicesEnabled]) {
       NSLog(@"Location is enabled.");
       return true;
   } else {
       NSLog(@"Location is disabled.");
       return false;
   }
}
- (BOOL) isLocationAuthorized
{
   if([CLLocationManager  authorizationStatus] != kCLAuthorizationStatusDenied) {
       NSLog(@"This app is authorized to use location.");
       return true;
   } else {
       NSLog(@"This app is not authorized to use location.");
       return false;
   }
}

Checked timestamps entries with NSLog for 'isLocationEnabled' and 'isLocationAuthorized', it takes more than 10 seconds to execute isLocationEnabled and 1 second to execute isLocationAuthorized.And also giving warning '['Diagnostic'] took '52807.718994' ms. Plugin should use a background thread'. Mostly happened when we resume the app from background. Could anyone please answer why it is taking more time to execute isLocationEnabled?

Xcode Log:

2015-11-17 19:35:58.026 AppName Loading Location status...
2015-11-17 19:36:50.481 AppName Location is enabled.
2015-11-17 19:36:50.816 AppName This app is authorized to use location.
2015-11-17 19:36:50.833 AppName THREAD WARNING: ['Diagnostic'] took '52807.718994' ms. Plugin should use a background thread.

iOS requestLocationAuthorization's success callback executes immediately

User if this is a bug or a problem with the wording in the documentation.

The success callback function of requestLocationAuthorization is being called immediately / as soon as the dialog is shown on iOS. My expectation is that it must be called once the user allows usage of device location, as it already does so on Android.

Experienced on a iOS 9.3 iPhone 6.

Adding new permissions check ?

Hello !

First of all, thank you (again) for that good job !
It works like a charm and it works around all the plugins not up to date with android 6 permissions system !

Still it could be an even more "ultimate" plugin if other permissions types were also implemented.
For example :

  • Contacts access
  • SMS access
  • Calendar access
  • Microphone access
  • Sensors access

This is of course just a suggestion, it's already pretty cool to have what you already did :)
I just wish i had more native coding knowledge to help you insteady of just suggesting/requesting things..

Anyways,
Thank you again for sharing your work !

Have a good day !

Selective Permissions

Is it possible to cherry-pick the different "uses-permissions" for Android? Would like to keep them to a minimum as I'm only using one. Looking through the source and I'm wondering whether this will break the plugin.

Camera permission denied despite being 'GRANTED'

I am using the following code to check for permissions on Marshmallow before taking a picture:

//check permission
window.cordova.plugins.diagnostic.isCameraAuthorized(function(response) {
  if (response) {
    $rootScope.permissions.camera = true;
    _openCamera();
  } else {
    // request permission
    cordova.plugins.diagnostic.requestCameraAuthorization(function(permission) {  
      if (permission === 'GRANTED') {
        $rootScope.permissions.camera = true;
        _openCamera();
      }
    }, function(error) {
      console.error(error);
    });
  }
}, function(error) {
  console.log(error);
});

_openCamera(); will run the code to open the camera, but the app crashes with:

Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/uk.ac.imperial.epicollect5.ionic/cache/.Pic.jpg} (has extras) } from ProcessRecord{99d2ee 7527:uk.ac.imperial.epicollect5.ionic/u0a79} (pid=7527, uid=10079) with revoked permission android.permission.CAMERA

I get the popup, I tap allow, the permission is GRANTED but still the camera crashes. If I look at the app permission settings, camera is still off after granting permission.

Any suggestions?

requestLocationAuthorization error on iOS7

Gettiing the following error after calling 'requestLocationAuthorization' method on iOS 7 device:

[CLLocationManager requestWinInUseAuthorization]:
unrecognized selector sent to instance 0x194812c0

requestRuntimePermissions: 'result' undefined

It seems checkForInvalidPermissions is getting called and "result" is undefined:

var valid = true, invalidPermissions = [];
...
if(invalidPermissions.length > 0) {
errorCallback("Invalid permissions specified: "+result.invalidPermissions.join(", "));
}

Does the variable "result" need to be there?

Android isLocationEnabled always returns '1'

Hello. I have cordova/ionic app. If after installing the app, I go to it's settings and disable location services, I always get successCallback: '1' when doing cordova.plugins.diagnostic.isLocationEnabled. Is it expected? Can I somehow check if location services permission is turned off for current app?

How check after switchToLocationSettings()

Hi,

How do you guys do to check if location was enabled after switch to location settings screen?

Because the user could just get back to the app without enable the GPS right? We have to check again and again until have sure that is enable.

Maybe if switchToLocationSettings returns a promise... I don't know

How did you solve that?

Thank you!

requestLocationAuthorization - Can't find variable: error

When using requestLocationAuthorization in iOS with and without passing in "when_in_use"

cordova.plugins.diagnostic.requestLocationAuthorization(function(){
console.log("Successfully requested location authorization always");
}, function(error){
console.error(error);
}, "when_in_use");

Error in Error callbackId: Diagnostic786250294 : ReferenceError: Can't find variable: error

iPhone4 iOS 7.1.2 Crash

Hello,

I have a crach in iPhone4 and iPhone4s iOS 7.1.2. I can reproduce 100% on call cordova.plugins.diagnostic.switchToSettings. In other devices is working perfect. I'm using Phonegap Build.

Thanks !

Wifi error reported, but device is using it.

Device Model: SproutChannelCubby
Android version: 4.4.2
Processor: QuadCore-A31
Phonegap Build verison: cli-5.2.0
ERROR Exception occured: WifiService: Neither user 10137 nor current process has android.permission.ACCESS

To be clear, the device only has wifi and the wifi is on.
I made this call:
cordova.plugins.diagnostic.isWifiEnabled()

Source code
Downloadable Build

Screenshot of error

Android 6.0 Permission granted but not allowed for requesting CurrentLocation

Hi,

I'm not entirely sure that the runtime permissions on Android 6.0 work. I added everything as told, received granted everytime i requested the permissions ( build was set on Android sdk 23 and it was the only version).

Then i request my current position, i always receive:

message: application does not have sufficient geolocation permissions.

But i requested the runtime permissions earlier on, and the return was:

Successfully requested location authorization

My Androidmanifest was the same as the one when i had sdk 22 as target, so i didn't remove anything there. The issue seemed the runtime permissions.

Could you add a button on your example app which requests your current location? Because i think it doesn't receive the right permissions somehow.

- Add the geolocation plugin

            var posOptions = { timeout: 35000, enableHighAccuracy: true, maximumAge: 5000 };
            navigator.geolocation
              .getCurrentPosition(function(position) {
                  var lat = position.coords.latitude;
                  var long = position.coords.longitude;
              }, function (err) {
                  console.log(err.code + " " + err.message);
              });

Nice to have - a better NPM package / plugin name

If I may recommend a slight twist to the current NPM package / plugin name cordova.plugins.diagnostic.
How about cordova-plugin-diagnostics?

Most (and the more popular) Cordova and third-party plugin names start with "cordova-plugin-". Seems to be the standard these days.

Requesting Camera or Location Authorization no Popup

I am using Cordova 5.1.1 against Android Marshmallow. Once Cordova has initialized I am checking for Camera access like so:

    cordova.plugins.diagnostic.getCameraAuthorizationStatus(
        function (access) {
            $constants.HasCameraAccess = access;
        },
        function (error) {
            alert("Camera Authorization Error: " + error);
        }
    );

Then when the user attempts to scan a barcode with the application I am checking my HasCameraAccess variable and if it is set to "NOT_REQUESTED" then I am attempting to prompt for access like so:

            cordova.plugins.diagnostic.requestCameraAuthorization(
                function (access) {
                    $constants.HasCameraAccess = access;
                },
                function (error) {
                    alert("Camera Authorization Error: " + error);
                }
            );

The issue that I am having is that the pop up to ask the user for permission is never showing, and a second attempt at requestCameraAuthorization is always returning "DENIED_ALWAYS".

Any ideas as to what I'm doing wrong?

Thanks,
Eric

Android: first call to requestLocationAuthorization always returns a wrong value

On Android, if you install the app for the first time, the first call to requestLocationAuthorization always returns GRANTED without waiting for the user choice.

I debugged this further, and turns out the 'GRANTED' is returned by mistake by combineLocationStatuses(). If I use requestRuntimePermission directly in my program, then the first call always returns 'undefined' (it correctly shows the choice dialog, but returns before the user chooses an option). All subsequent call to requestRuntimePermissions() work properly as documented.

the CameraAuthorization is wrong

in your example the diagnostic.js
Diagnostic.requestCameraAuthorization = function(successCallback, errorCallback){
Diagnostic.requestRuntimePermission(successCallback, errorCallback, Diagnostic.runtimePermission.CAMERA);
};
is right,but when we use cordova insall the plugin the method is
Diagnostic.requestCameraAuthorization = function(successCallback, errorCallback){
function onSuccess(statuses){
successCallback(combineCameraStatuses(statuses));
}
Diagnostic.requestRuntimePermissions(onSuccess, errorCallback, [
Diagnostic.runtimePermission.READ_EXTERNAL_STORAGE
]);
};

is that paste wrong ???

No Callback

I'm requesting a permission, and a couple of other things (isCameraAuthorized etc.) all at the same time, and sometimes I don't get a callback (not even a failure) - almost always on my requestRuntimePermission.

Is this an issue, or is it considered best practice to chain these requests rather than async?

PhoneGap: diagnostic plugin is not working in iphone

I am trying to use diagnostic plugin in my ios app built by phonegap Build. It's working fine for android but it's not working in ios.

It is not showing any error in remote debug (console).

I am using following two files to build this app:

index.html and config.xml
(Code is provided: http://stackoverflow.com/questions/35373948/phonegap-diagnostic-plugin-is-not-working-in-iphone)

I am not getting any error. I reasearched alot about this issue but no vain. I'll really appreciate any response.

Can we open location setting in ios?

I want to know, Can we open Location setting in iPad4 wifi? I think there have code for GPS location enable or not. What we do for open the Location Setting?

Uncaught ReferenceError: module is not defined in Worklight 7.1

Hi,
I have used plugin in worklight 7.1 hybrid project, when I run the project following error has occured
On browser- Uncaught ReferenceError: module is not defined
on android device - undefined is not a function
When I made following changes in diagnostic.js it worked fine
window.Diagnostic = window.Diagnostic || {};
window.Diagnostic = new Diagnostic();

Support for both Android API 23 and 19 for isLocationEnabled?

Hi, I'm not clear from reading the documentation about using the latest version to call isLocationEnabled(). If I use the latest version and build using SDK version 23, will the function return the correct value when called from both Marshmallow (API 23) and a KitKat (API 19) devices?

Question/Request: switchToLocationSettings for iOS

Is there a way to send the user directly to Settings->Privacy->Location Services on iOS? Just like switchToLocationSettings works for Android.
cordova.plugins.diagnostic.switchToSettings has a different purpose for iOS.

I am wondering if this can be a doable and possible enhancement for this plugin or if there is any other alternative.

Background: https://forum.ionicframework.com/t/ios-plugin-for-sending-user-to-settings-privacy-location-services/42273

Question: microphone permission on Android

Hi there, I have a question

I am recording audio on Android, and I noticed the requestMicrophoneAuthorization() is iOS only

What happens if I need this permission on Android Marshmallow?

<uses-permission android:name="android.permission.RECORD_AUDIO" />

Your plugin does not provide any method to check if that permission is granted on Android or am I missing something?

diagnostic is undefined

If I access the plugin through cordova.plugins.diagnostic I get an error because is undefined.

I solved it accessing the plugin like this -> window.Diagnostic (with a capital D)

Problem on android earlier version than kitkat

Hi,

I´m developing an app using ionic, and I have used this plugin to detect if the user has the location enabled or not.

I was having an exception problem if the android version was earlier than kitkat (19). So I have modified the plugin code to get it works, but I don´t know if my changes are correct.

In the function getLocationMode() I have change the code with this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
return Settings.Secure.getInt(this.cordova.getActivity().getContentResolver(), Settings.Secure.LOCATION_MODE);
}else{

        LocationManager locationMgr = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
        if(!locationMgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER) && !locationMgr.isProviderEnabled(LocationManager.GPS_PROVIDER)){
            return 0;
        }else{
            if(locationMgr.isProviderEnabled(LocationManager.GPS_PROVIDER)){
                return 3;
            }else{
                if(locationMgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
                    return 2;
                }else{
                    return 0; //no provider detected
                }
            }
        }
    }

I have change the functions isgpslocationenabled and isnetworklocationenabled too, because there was a problem with Settings.Secure. I don´t lnow if is there another way to solve my problem.

Thanks and greetings

isLocationEnabled needs GPS enabled for returning true on Android

Is there a reason for only checking GPS when calling isLocationEnabled on Android?

https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/src/android/Diagnostic.java#L89

Why not doing something like this?

callbackContext.success((isGpsEnabled() || isNetworkEnabled()) ? 1 : 0);

Just tested it on Android 4.4.4. It worked like a charm.

Because you write something about GPS has to be enabled to get true for isLocationEnabled in your readme explicitly, i think there must be a reason for this.

Thanks and greetings
wanja

Cordova diagnostic + Crosswalk

Hi everyone,

Just a quick question did any body of you encountered a build error after installing crosswalk + cordova diagnostic.

Or do you know any other plugin that I can use to enable gps/location.

Happy Coding <3 :D

App build fails due to plugin when upgraded to cordova-ios 4.0.x

I upgraded to cordova-ios 4.0.1 post which my ionic app is failing to build

There are many plugins which are failing out of which diagnostic is also the one.
i had posted the issue on cordova-ios issue tracker and @shazron have reverted with suggestions to fix the plugin as many deprecated methods have been removed in cordova-ios 4.0.1.
https://issues.apache.org/jira/browse/CB-10310

Info on the code breaks and fixing them
http://cordova.apache.org/announcements/2015/12/08/cordova-ios-4.0.0.html
http://cordova.apache.org/news/2015/11/24/plugins-release.html

Also attaching the exact error for the plugin with [email protected]
screen shot 2015-12-23 at 22 26 00

only "registerLocationAuthorizationStatusChangeHandler" not work in iOS

hi @dpa99c
I am using PGB 5.2.0 with your plugin with version 2.1.0 + iOS 9.0.2 (13A452)
all function perfect work in addition to "registerLocationAuthorizationStatusChangeHandler"

cordova.plugins.diagnostic.registerLocationAuthorizationStatusChangeHandler(function(status){
    alert("Location authorization status changed to: "+status);
});

no any alert appear after I change the location service on to off or off to on

cordova can oly give me old version + isLocationEnabled() is not working

First, thanks for your work. I was looking for this plugin.Unfortunately, I ran into two problems.

I install the plugin follow the instruction in my local:

$ cordova plugin add cordova.plugins.diagnostic
Fetching plugin "cordova.plugins.diagnostic" via cordova plugins registry
npm http GET http://registry.cordova.io/cordova.plugins.diagnostic
npm http 200 http://registry.cordova.io/cordova.plugins.diagnostic
npm http GET http://cordova.iriscouch.com/registry/_design/app/_rewrite/cordova.plugins.diagnostic/-/cordova.plugins.diagnostic-1.1.0.tgz
npm http 200 http://cordova.iriscouch.com/registry/_design/app/_rewrite/cordova.plugins.diagnostic/-/cordova.plugins.diagnostic-1.1.0.tgz
Installing "cordova.plugins.diagnostic" for android
Installing "cordova.plugins.diagnostic" for ios

The version is 1.1.0, but not 2.1.0 listed in npm?! Some how the cordova use the version in Cordova Registry. Any idea? BTW, I also used phonegap build too(<gap:plugin name="cordova.plugins.diagnostic" source="npm" />), but I cannot validate the version thru their UI.

2 problem:
When my gps settings is totally off(GPS+wifi), the following code will still return me success, having an alert claiming the device is gps ready:

function checkLocationState(){
cordova.plugins.diagnostic.isLocationEnabled(
function(){alert("ready?");},
function(err){
var settingFxn;
if($rootScope.UTIL.osType = "android")
settingFxn = cordova.plugins.diagnostic.switchToLocationSettings;
else
settingFxn = cordova.plugins.diagnostic.switchToSettings;
settingFxn(
function(){
alert("Successfully switched to Settings app");
},
function(error){
alert("The following error occurred: "+error);
});
});
}
document.addEventListener('resume', checkLocationState, false);
document.addEventListener('deviceready', checkLocationState, false);

The problem is in iOS and Android.

Just FYI, we use local build to test Android and phonegap build to test iOS.

Adding the plugin has compilation problems

I'm having the following error when building using cordova-diagnostic-plugin.

The build error comes as soon as i add the plugin and doesn't even go away when i remove the plugin.
I don't have any resources there, yet it searches for them.

Any thoughts on what it could be?

debug-runtime-permissions

Issues with the library

platforms/android/src/cordova/plugins/Diagnostic.java:411: cannot find symbol
symbol : method shouldShowRequestPermissionRationale(android.app.Activity,java.lang.String)
location: class android.support.v4.app.ActivityCompat
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(this.cordova.getActivity(), androidPermission);
^
platforms/android/src/cordova/plugins/Diagnostic.java:565: cannot find symbol
symbol : method shouldShowRequestPermissionRationale(android.app.Activity,java.lang.String)
location: class android.support.v4.app.ActivityCompat
boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(this.cordova.getActivity(), androidPermission);
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /platforms/android/src/cordova/plugins/Diagnostic.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
100 warnings
:compileDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED```

Uncaught ReferenceError: module is not defined in Worklight 7.1

Hi,
I am using the cordova plugin in my MobileFirst Platform foundation 7.1
(eclipse plugin). I have installed the cordova-diagnostic-plugin malually.
When I try to run the project I face following error

Uncaught ReferenceError: module is not defined diagnostic.js 669

So can you help me to understand why this issue is been occured?

I have done following workaround to resolve the issue.

window.Diagnostic = new Diagnostic();

Always returning permission granted even if disabled

On Android Marshmallow, The plugin is returning "Granted" even when I go to settings and disable that specific permission. In my case, I got a "Granted" on camera runtime permission check even when I had disabled it through settings. Android is unable to open camera post that though since the permission is in reality disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.