Giter VIP home page Giter VIP logo

permissionsplugin's Introduction

Permissions Plugin for Xamarin

Simple cross platform plugin to request and check permissions.

Want to read about the creation, checkout my in-depth blog post.

I have been working on Plugins for Xamarin for a long time now. Through the years I have always wanted to create a single, optimized, and official package from the Xamarin team at Microsoft that could easily be consumed by any application. The time is now with Xamarin.Essentials, which offers over 50 cross-platform native APIs in a single optimized package. I worked on this new library with an amazing team of developers and I highly highly highly recommend you check it out.

Additionally, Xamarin.Essentials is now included in & .NET MAUI.

Due to the functionality being included "in the box" I have decided to officially archive this repo.

Setup

Platform Support

Platform Version
Xamarin.iOS iOS 8+
Xamarin.Android API 14+
Windows 10 UWP(Beta) 10+

*See platform notes below

Build Status: Build status

Android specific in your BaseActivity or MainActivity (for Xamarin.Forms) add this code:

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
    PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

Android Setup

This plugin uses the Xamarin.Essentials, please follow the setup guide.

Xamarin.Essentials.Platform.Init(this, bundle);

iOS Specific

Based on what permissions you are using, you must add information into your info.plist. Please read the Working with Security and Privacy guide for keys you will need to add.

API Usage

You are able to check and requests permissions with just a few lines of code:

Check permission:

PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync<CalendarPermission>();

Request permission:

PermissionStatus status = await CrossPermissions.Current.RequestPermissionAsync<CalendarPermission>();

Additionally on Android there is a situation where you may want to detect if the user has already declined the permission and you should show your own pop up:

bool shouldShow = await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Calendar);

Available Permissions

  • CalendarPermission
  • CameraPermission
  • ContactsPermission
  • LocationPermission
  • LocationAlwaysPermission
  • LocationWhenInUsePermission
  • MediaLibraryPermission
  • MicrophonePermission
  • PhonePermission
  • PhotosPermission
  • RemindersPermission
  • SensorsPermission
  • SmsPermission
  • StoragePermission
  • SpeechPermission

In Action

Here is how you may use it with geolocation:

try
{
	var status = await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission>();
	if (status != PermissionStatus.Granted)
	{
		if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
		{
			await DisplayAlert("Need location", "Gunna need that location", "OK");
		}

		status = await CrossPermissions.Current.RequestPermissionAsync<LocationPermission>();
	}

	if (status == PermissionStatus.Granted)
	{
		//Query permission
	}
	else if (status != PermissionStatus.Unknown)
	{
		//location denied
	}
}
catch (Exception ex)
{
  //Something went wrong
}

Read more about android permissions: http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous

IMPORTANT

Android:

You still need to request the permissions in your AndroidManifest.xml. Also ensure your MainApplication.cs was setup correctly from the CurrentActivity Plugin.

Windows 10 UWP

UWP has a limited set of supported permissions. You can see the documentation above, but current support: Contacts, Location, and Sensors.

Contributors

Thanks!

License

Licensed under main repo license(MIT)

Want To Support This Project?

All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down! Want to go further? Make sure to subscribe to my weekly development podcast Merge Conflict, where I talk all about awesome Xamarin goodies and you can optionally support the show by becoming a supporter on Patreon.

permissionsplugin's People

Contributors

aritchie avatar azureadvocatebit avatar diegostamigni avatar hvaughan3 avatar jamesmontemagno avatar jcmanke avatar prashantvc 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

permissionsplugin's Issues

Permissions- InvalidOperationException: transition a task to a final state

Received an exception report within Google Play Store site from a production user. The StackTrace is listed below.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
... 1 more
Caused by: android.runtime.JavaProxyThrowable: System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
at System.Threading.Tasks.TaskCompletionSource`1[TResult].SetResult (System.Threading.Tasks.TResult result) <0x9770c2e8 + 0x0004c> in :0
at Plugin.Permissions.PermissionsImplementation.OnRequestPermissionsResult (Int32 requestCode, System.String[] permissions, Android.Content.PM.Permission[] grantResults) <0x9770c000 + 0x0020b> in :0
at APP.Droid.MainActivity.OnRequestPermissionsResult (Int32 requestCode, System.String[] permissions, Android.Content.PM.Permission[] grantResults) <0x98023c80 + 0x00033> in :0
at Android.App.Activity.n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI (IntPtr jnienv, IntPtr native__this, Int32 requestCode, IntPtr native_permissions, IntPtr native_grantResults) <0x980239b8 + 0x0011b> in :0
at (wrapper dynamic-method) System.Object:01b25bb4-ee19-4a08-9b1e-0f10bc1cbad2 (intptr,intptr,int,intptr,intptr)
at md53544c7d34300ea24a1c2b39d6d0f2051.MainActivity.n_onRequestPermissionsResult(Native Method)
at md53544c7d34300ea24a1c2b39d6d0f2051.MainActivity.onRequestPermissionsResult(MainActivity.java:56)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7263)
at android.app.Activity.dispatchActivityResult(Activity.java:7141)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4916)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4963)
at android.app.ActivityThread.access$1600(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1848)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
... 3 more

Bug

Version Number of Plugin: 1.1.7
Device Thrown On: Samsung Galaxy S5 - Android 6.0

Expected Behavior

An exception is not thrown.

Actual Behavior

An exception is thrown.

Steps to reproduce the Behavior

Unfortunately I am not able to recreate the issue because I am not sure what caused it and do not know who the user is that submitted the exception. I am wondering if this could be caused by the user double-tapping a control or something like that which would cause OnRequestPermissionsResult() to run multiple times, which would make the TaskCompletionSource<Dictionary<Plugin.Permissions.Abstractions.Permission, PermissionStatus>> throw the exception.

Flipping Usage Descriptions on iOS Location

It looks like the location usage checks for iOS are correct in source code; however, it doesn't look like those changes are in the compiled version on NuGet. Could you please promote? Thanks!

[UWP]CheckPermissionStatusAsync unexpectedly popping up dialog

Bug

Version Number of Plugin: 1.2.1
Device Tested On: Windows 10 desktop, built as x86 but running on x64 (an issue in Xamarin.Auth is preventing build of x64 at present)

Expected Behavior

CheckPermissionStatusAsync should return a value but not pop up a dialog
RequestPermissionsAsync should pop up a dialog

Actual Behavior

CheckPermissionStatusAsync pops up the dialog saying

Let YourApp access your precise location?
To change this later, go to the Settings app.
Yes No

Make MainApplication partial

Not a bug. However, lets say framework X implement their own Application class, it would be desirable to have both this and the framework's Application class co-exist.

Would it be possible to mark MainApplication partial along with the methods it implements?

CrossPermissions.Current.RequestPermissionsAsync always returns PermissionStatus.Unknown.

CrossPermissions.Current.RequestPermissionsAsync always returns PermissionStatus.Unknown.

Bug

Version Number of Plugin: 1.2.1
Device Tested On: Android 6.0 OS
Simulator Tested On:

Expected Behavior

CrossPermissions.Current.RequestPermissionsAsync should return the status as PermissionStatus.Granted.

Actual Behavior

CrossPermissions.Current.RequestPermissionsAsync always returns PermissionStatus.Unknown.

Steps to reproduce the Behavior

Request the permission using the below statement in dependency service in android project.

var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage });

cameraStatus = results[Permission.Camera]; //CameraStatus is always returned as PermissionStatus.Unknown

I am using the plugin.currentactivity in android project.

Note: I am writing the above code in custom control and using it later in the actual application.

RequestPermissionsAsync(Permission.Sensors) always returns PermissionStatus.Denied in iOS emulator

the method RequestPermissionsAsync(Permission.Sensors) returns PermissionStatus.Denied even after allowing access to NSMotionUsageDescription in iOS iPhoneSimulator (clicking 'Ok' button)

Version Number of Plugin: 1.2.1
Device Tested On: Emulator only
Simulator Tested On: iPhone 6 iOS 10.1

Expected Behavior

returned value is PermissionStatus.Granted

Actual Behavior

returned value is PermissionStatus.Denied

Steps to reproduce the Behavior

repro steps:

  1. Add the following property to info.plist:
    NSMotionUsageDescription
  2. Call CrossPermissions.Current.RequestPermissionsAsync(Permission.Sensors);
  3. When prompted, click 'Ok' button in permission dialog
  4. Check returned value

await permissions.RequestPermissionsAsync simply not returning anything

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

Version Number of Plugin: 1.2.1
Device Tested On:
Simulator Tested On:
Version of VS: Professional 2017
Version of Xamarin: 2.3.4.247
Versions of other things you are using: Target and build in api 25 on adroid

Steps to reproduce the Behavior

var results = await permissions.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];

Expected Behavior

To return permission results. Are there any conflicts with API 25?? I have included the overridden method in MainActivity.cs

Actual Behavior

no results returned and nothing in the stack trace. application is running, just never stops awaiting response.

Code snippet

var results = await permissions.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];

Screenshotst

Problem in the MAC

After I install the package, I receive a error on the build time

This message is show

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error: java.lang.IllegalArgumentException: already added : Landroid/support/v4/view/VelocityTrackerCompat; (Project.Droid)

Bug Information

Version Number of Plugin: 2.0.1
Version of VS: VS for MAC
Version of Xamarin: Xamarin Forms 2.3.4.231
Versions of Framework: .NET Portable: PCL 4.6 - Profile44

Errors on package install

Bug

Version Number of Plugin: 1.1.7
Device Tested On: Did not get that far
Simulator Tested On: See above

Expected Behavior

NuGet Installs the plugin

Actual Behavior

Package Manager Console Host Version 3.5.0.1484

Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package Plugin.Permissions -Version 1.1.7
Install-Package : Project 'Default' is not found.
At line:1 char:1

  • Install-Package Plugin.Permissions -Version 1.1.7
  • - CategoryInfo          : ObjectNotFound: (Default:String) [Install-Package], ItemNotFoundException
    - FullyQualifiedErrorId : NuGetProjectNotFound,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

PM>

Steps to reproduce the Behavior

In Visual Studio Community 2015 Version 14.0.25425.01 Update 3, Tools, NuGet Package Manager, Package Manager Console, then type command line as above.

Sorry if this is a newbe problem, but I am one in this area and I am following the instructions to the best of my ability!

Permission dialog never displayed when Target Android Version is set to "Automatic"

Bug

On Android 6.0+ The plugin doesn't display a permission dialog when the Target Android Version is set to "Automatic - user target framework version (API 25)"

The ReadMe does say

You MUST set your Target version to API 23+ and Compile against API 23+

Does setting the Target Android Version to "Automatic - user target framework version (API 25)" meet this criteria, or does the instruction mean that the Target Android Version must be set explicitly?

Version Number of Plugin: 1.2.1
Device Tested On: Nexus 5x running Android v7.1.1
Simulator Tested On: N/A
IDE: Xamarin Studio

screen shot 2017-04-06 at 5 04 17 pm

screen shot 2017-04-06 at 5 04 22 pm

Expected Behavior

Plugin should display the permission dialog

Actual Behavior

No permission dialog is displayed

Steps to reproduce the Behavior

1.)Uninstall existing app
2.)Open Android Manifest
3.)Set Target Android Version to "Automatic - user target framework version (API 25)"
4.)Install and run app

[Feature] Android Permission - Use Blank Activity

From @aritchie on January 23, 2016 18:26

Hey James

I would love to use the permissions plugin, but the hack of dropping in the same block of code per activity just doesn't sit with me. Something I was considering doing was a transparent activity that can request the permission and dialogs while staying under the control of the plugin. You also wouldn't need your top activity plugin any longer to accomplish this. You could do Application.Context.StartActivity(typeof(TransparentPermissionPluginActivity));

I'll do a PR if you're interested.

Copied from original issue: jamesmontemagno/Xamarin.Plugins#197

Bluetooth Permission on Android

Hi James,
looking at the code, it seems that currently the Bluetooth permission is not supported on Android, am I right?
Do you have any plan to support it in the future?

Thanks,
Marco.

I DON'T KNOW WHICH TITLE FOR THIS ERROR?

I try with New Empty Project

  1. Install Plugin.Permission of James Montemagno
  2. I get this error "java.lang.IllegalArgumentException: already added : Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;"
  3. I try Enable Multi-Dex
  4. I get this error "Can't write [C:\Users\nguye\AppData\Local\Temp\mainDexClasses-11498.tmp.jar] (Can't read [C:\Users\nguye\AppData\Local\Xamarin\Xamarin.Android.Support.v4\23.3.0.0\embedded\classes.jar] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewCompat$JbMr1ViewCompatImpl.class]))"
  5. No comment!

App Crash when I PushModalAsync a new page while Permission popup is shown.

If I PushModalAsync a new page while permission popup is still shown on Android(with forms AppCompat).
App crash.

My new modal page needed to be pushed automatically in some case like a announcement.

I could set boolean variable before await RequestPermissionsAsync and after, to open new page while popup is not shown to avoid crash. (It's working fine)

But I think there is better solution.
Any suggestion?

Permissions denied or unknown

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin: 1.2.1
Device Tested On: Nexus 6p
Simulator Tested On:

Behavior

Using the Geolocator plugin I call GetPositionAsync() which is not going through and I get the message that permissions are denied. I afford the device all permissions I need in the AndroidManifest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

This did not allow me to get the location. So further researching I found an issue from another person on here that you told to do in manually. So I did that via ShouldShowRequestPermissionRationaleAsync(). The permission comes back unknown.

Is there any reason that possibly the manifest would be ignored or this would be unknown

Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.

I get the following error after adding the permissions plugin to my android app.

Error MSB4018: The "GenerateJavaStubs" task failed unexpectedly.
System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.
at Xamarin.Android.Tasks.ManifestDocument.CreateApplicationElement(XElement manifest, List1 subclasses, List1 selectedWhitelistAssemblies)
at Xamarin.Android.Tasks.ManifestDocument.Merge(List1 subclasses, List1 selectedWhitelistAssemblies, Boolean embed, Boolean replaceSplashScreen, IDictionary2 splashScreenClasses, String bundledWearApplicationName, IEnumerable1 mergedManifestDocuments)
at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() (MSB4018)

Not seeing 'system prompt' for the ReadCalendar permission when the build target is set to 'automatic'

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Hi,.. I am using the latest version of “Plugin.Permission" from the nuget to my app. I have been spending few hours to figure out why I keep NOT able to see the ‘system prompt’ when I ask for the Permission to ReadCalendar (via the RequestPermissionsAsync() method). At the end, ..I think I found a bug…

According to your spec, it has to be at least SDK >= 23. My target is 24. So,..by right I should see the ‘prompt’. According to my test results:

  1. If I set the target android version explicitly to: override - Android 7.0 (API level 24), or to override - Android 6.0 (API level 23), then I will see the prompt.
  2. However, my setting was:
    Target Android version: Automatic - use target framework version (API 24). Whenever it is with ‘Automatic - then no prompt will be shown.

Version Number of Plugin: 1.2.1
Device Tested On: Samsung Galaxy S6, Android version: 6.0.1

Expected Behavior

Should see the 'Prompt' after the requestPermissionAsync method() even if I have the target build set to automatic - use target framework version (API 24).

Actual Behavior

Whenever it is with ‘Automatic - then no prompt will be shown.

Please add NSAppleMusicUsageDescription

Feature Request:

Please fill in what you would like

I'm trying to access the iPOD library with MPMediaQuery this requires in pInfo but I think I have to request it also from the App because my App is not halted while the OS asks for the permission and therefore crashes.

Unfortunately this permission is not yet implemented in the plugin.

Would be great if you could add it.

Best
THomas

#Bug CheckPermissionStatusAsync(Permission.Calendar) on Andriod always returns Granted

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin:
1.2.1
Device Tested On:
NVIDIA Shield
Android 6.0.1

Expected Behavior

var val = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);
val should be Denied.

Actual Behavior

val is Granted

Steps to reproduce the Behavior

In System App settings deny permission to camera, ect.
Run app with plugin

MainApplication class

Hi,

Your plugin contain MainApplication class with [Application] attribute.
I want to have my own MainApplication in my application but I cannot do this because an application cannot use more than one class with [Application] attribute.
Is there any way to achieve this?

Regards

Even if I manually disable camera permission, It's still say "Granted".

Bug

Version Number of Plugin: 1.2.1
Device Tested On: LG G3(Android 6)
Simulator Tested On:

Actual Behavior

I manually set Permission to off in Android app setting and try this
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);

It's still say "Granted" and app crash because I try to use Camera.
(in debug test)

It's not happening to you?
Am I wrong somewhere?

Thanks.

Steps to reproduce the Behavior

Android dependencies for API 24+

Plugin.Permissions requires Xamarin.Android.Support.v4. Unfortunately other Xamarin packages, like AppCompat, that used to require this library (in versions up to 23.4.0.1) now require things like Xamarin.Android.Support.Core.Utils, which define the same symbols. This means that in order to compile projects that use both Plugin.Permissions and AppCompat, I need to use the 23.x version of AppCompat et al, not the 24.x version.

Currently I don't need the 24.x versions of Xamarin's support library; I can get by with the 23.x versions. But it seems like something to keep in mind.

RequestPermissionsAsync returns empty Dictionary

Bug Information

Version Number of Plugin: 1.2.1
Device Tested On: Samsung SM-G930F Android 7.0
Simulator Tested On: ?
Version of VS: VS2015
Version of Xamarin: ?
Versions of other things you are using: ?

Steps to reproduce the Behavior

Can't reproduce locally, but got a single HockeyApp crash, where a call to RequestPermissionsAsync yielded an empty dict.

Expected Behavior

Returned dict should always have some kind of status for requested key

Actual Behavior

💥

Code snippet

var results = await permissions.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];

Similar to your samples.

Stack trace

Stack from HockeyApp:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x00021] in <e25755e715fc46b8b923cdc234258b18>:0 
  at NoiseSentinelApp.ViewModels.PublicSitesViewModel+<CheckPermissions>d__15.MoveNext () [0x00111] in <6056251c9e574471a64169ec91935eb0>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <e25755e715fc46b8b923cdc234258b18>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <e25755e715fc46b8b923cdc234258b18>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <e25755e715fc46b8b923cdc234258b18>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <e25755e715fc46b8b923cdc234258b18>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <e25755e715fc46b8b923cdc234258b18>:0 
  at NoiseSentinelApp.ViewModels.PublicSitesViewModel+<<Initialize>b__10_0>d.MoveNext () [0x0006a] in <6056251c9e574471a64169ec91935eb0>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <e25755e715fc46b8b923cdc234258b18>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in <e25755e715fc46b8b923cdc234258b18>:0 
  at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in <fbcbadf806a6438189c71b1942dc782b>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <fbcbadf806a6438189c71b1942dc782b>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <fbcbadf806a6438189c71b1942dc782b>:0 
  at (wrapper dynamic-method) System.Object:a589cd34-2cad-42ed-8843-c1f03f41d0d9 (intptr,intptr)
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6692)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Should be able to capture the photos in square shape

I have a requirement to capture the image in the form of square (or) provide an option for pan/crop captured image in the image preview before saving.

Expected Behavior

Should be able to capture the images in the square shape in both android and iOS.

Actual Behavior

Currently there is no option to capture the image in the form of square in Android and iOS devices.

Steps to reproduce the Behavior

Feature Request:

I have a requirement to capture the image in the form of square (or) provide an option for pan/crop captured image in the image preview before saving.

NuGet packages not up to date

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

NuGet package currently published (1.2.1) does not include recent fixes, specifically the permissions check order flip on iOS from 23/Dec/16 (f18dfde#diff-0231fffb2dcaf285d46c31f201305e10 )

Version Number of Plugin: NuGet 1.2.1 / current release
Device Tested On: n/a
Simulator Tested On: iOS 10 Simulator

Expected Behavior

iOS Location 'Always' setting is given precedence over 'When In Use' per the above commit via NuGet package

Actual Behavior

NuGet package is old and does not include the above fix

Steps to reproduce the Behavior

Using current NuGet package 1.2.1, on iOS project add both Always and When In Use location permission requests to info.plist, then use the plugin to request permission.

Doesn't give priority to Always option, which was fixed in the commit referenced above.

Feature Request:

Please fill in what you would like

[UWP] Accepted permission decision not stored on Windows 10 Desktop

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin: 1.2.1
Device Tested On: HP ElitePad 900

Expected Behavior

Once user accepts permissions, they shall be stored and user shall not be asked again.

Actual Behavior

User is asked each time to give permissions to application.

Steps to reproduce the Behavior

Create simple Xamarin.Forms UWP project that request some permissions in runtime, run app on Win 10.

Feature Request:

Please fill in what you would like

I can't compile my project

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin: latest
Device Tested On: none
Simulator Tested On: none

Expected Behavior

Can compile my project

Actual Behavior

I have add

    //Per permission plugin
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
    {
        PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

to my MainActivity.cs and add

using Plugin.Permissions;

but I have

Error CS0115: `IWapp.Droid.MainActivity.OnRequestPermissionsResult(int, string[], Android.Content.PM.Permission[])' is marked as an override but no suitable method found to override (CS0115) (IWapp.Droid)

Steps to reproduce the Behavior

follow your github readme

RequestPermissionsAsync hangs when calling with a Permission array

Bug

When passing the following permission array to RequestPermissionsAsync, the dialog for Permission.Sensors is never shown.
private static Permission[] permissionList = new Permission[]
{
Permission.Storage,
Permission.Camera,
Permission.Location,
Permission.Sensors
};

Version Number of Plugin: 1.2.1
Device Tested On: Emulator only
Simulator Tested On: iPhone 6 iOS 10.1

Expected Behavior

Permission dialog is shown for Permission.Sensors and RequestPermissionsAsync method returns.

Actual Behavior

Camera and Location dialogs are shown, then app hangs and RequestPermissionsAsync doesn't return

Steps to reproduce the Behavior

  1. Add the following properties to info.plist:
    NSCameraUsageDescription

    NSLocationWhenInUseUsageDescription

    NSMotionUsageDescription
  2. Call CrossPermissions.Current.RequestPermissionsAsync with the Permission array from above:
    var result = await CrossPermissions.Current.RequestPermissionsAsync(permissionList);

System.InvalidOperationExceptionAn attempt was made to transition a task to a final state when it had already completed.

Bug

System.InvalidOperationExceptionAn attempt was made to transition a task to a final state when it had already completed.
Raw
System.Threading.Tasks.TaskCompletionSource.SetResult(TResult result)<368820a9888f43ddb85d18e87189adbf>:0
Plugin.Permissions.PermissionsImplementation.OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)<47bb53b40691435f96893bccf92fcd93>:0
Sensus.Android.AndroidMainActivity.OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)<23556fa8db484a1f9fb76c2fcebf4564>:0
Android.App.Activity.n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(IntPtr jnienv, IntPtr native__this, int requestCode, IntPtr native_permissions, IntPtr native_grantResults)<148efd2f7a03496fb40611cf5f4f0bb1>:0
at (wrapper dynamic-method) System.Object:d20dfcf5-62be-4e27-8c5a-6c2b9ce6303b (intptr,intptr,int,intptr,intptr)

Version Number of Plugin: 1.1.7
Device Tested On: Android M
Simulator Tested On: None

Expected Behavior

No exception.

Actual Behavior

Exception.

Steps to reproduce the Behavior

Not sure. Got this in Insights.

Failed to resolve "Speech.SFSpeechRecognizerAuthorizationStatus"

When using this plugin with the media plugin my app wont build for a iOS 10 device (build with ios sdk 9.3) Building on the simulator with ios9 works fine.

The error i get is:
Failed to resolve "Speech.SFSpeechRecognizerAuthorizationStatus"

Version Number of Plugin: 1.2.1

#Bug CheckPermissionStatusAsync(Permission.Calendar) on Andriod always returns Granted

Bug

First thanks for this really sweet plugin!

Version Number of Plugin: v2.5.2.1
Device Tested On: Motorola Moto E second generation with 4G LTE on Android 6.0

Expected Behavior

When I install the app the calender permission is granted automatically which is fine and all works ok.
When I revoke the permission manually and I kill the app I would expect permission Denied or Disabled.

Actual Behavior

I get permission Granted while I revoked the calender permission for my app. When I try to get the calender list I won't get any calanders any more which is logical since it has no permissions any more.

Steps to reproduce the Behavior

I followed al steps in the plugin readme to the letter and on IOS it all works fine. On android I install the app, go to settings, apps, settings, app-permissions, Calender and I revoke the calender permission for my app. Then I restart the app and the CheckPermissionStatusAsync(Permission.Calendar) will return Granted. This is not what I would expect.

Permission location returns granted but is not (Android 6.0)

Bug

Version Number of Plugin: 1.7
Device Tested On: OnePlus x (5.1), OnePlus 3 (6.0)

Expected Behavior

In my app, I check for the location permission. On Android 5.1, if I change the permission to false, the status does not return granted.

Actual Behavior

However, with an Android 6.0 device, if I have accepted the request for location at the installation, even if I change the permission to false, it returns granted.

XF- Android: Exception when try to request Phone permission in Android OnCreate

Target SDK:

android:targetSdkVersion="25"

Packages:

<package id="Plugin.Permissions" version="2.0.1" targetFramework="monoandroid71" />
 <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Annotations" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Compat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.UI" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Core.Utils" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Design" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Fragment" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Media.Compat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Transition" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v4" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.CardView" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.Palette" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="25.3.1" targetFramework="monoandroid71" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="25.3.1" targetFramework="monoandroid71" />
    <package id="Xamarin.Build.Download" version="0.4.6" targetFramework="monoandroid71" />
  <package id="Xamarin.Forms" version="2.3.4.247" targetFramework="monoandroid71" />

Problem:

I try to get the Phone permission in the OnCreate event, but I get an exception at that statement:

var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] {Plugin.Permissions.Abstractions.Permission.Phone});

Exception:

07-11 08:45:54.825 D/Mono    (20216): Assembly Ref addref Xamarin.Forms.Platform.Android[0x98bfc600] -> Xamarin.Android.Support.v4[0x98bfc1e0]: 3
An unhandled exception occured.

07-11 08:45:55.555 W/System.err(20216): java.io.InterruptedIOException: thread interrupted
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.okio.Timeout.throwIfReached(Timeout.java:145)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.okio.Okio$1.write(Okio.java:78)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.okio.RealBufferedSink.flush(RealBufferedSink.java:221)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.http.HttpConnection.flush(HttpConnection.java:141)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.http.HttpTransport.finishRequest(HttpTransport.java:60)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:1118)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:951)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:482)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:418)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:235)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
07-11 08:45:55.555 W/System.err(20216): 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
07-11 08:45:55.555 W/System.err(20216): 	at net.hockeyapp.android.tasks.CheckUpdateTask.doInBackground(CheckUpdateTask.java:114)
07-11 08:45:55.555 W/System.err(20216): 	at net.hockeyapp.android.tasks.CheckUpdateTask.doInBackground(CheckUpdateTask.java:40)
07-11 08:45:55.555 W/System.err(20216): 	at android.os.AsyncTask$2.call(AsyncTask.java:295)
07-11 08:45:55.555 W/System.err(20216): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-11 08:45:55.555 W/System.err(20216): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
07-11 08:45:55.555 W/System.err(20216): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
07-11 08:45:55.555 W/System.err(20216): 	at java.lang.Thread.run(Thread.java:818)

Code:

        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            UserDialogs.Init(() => (Activity) Forms.Context);

            CrossVersionTracking.Current.Track();

            BootstrapHockeyApp();

            // Set the current instance of MainActivity.
            CurrentActivity = this;
            global::Xamarin.Forms.Forms.Init(this, bundle);

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;


            try
            {
                var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Plugin.Permissions.Abstractions.Permission.Phone);
                if (status != PermissionStatus.Granted)
                {
                    if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Plugin.Permissions.Abstractions.Permission.Phone))
                    {
                        DialogNotify("Need phone permission", "Gunna need that phone permission");
                    }

                    var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] {Plugin.Permissions.Abstractions.Permission.Phone});
                    status = results[Plugin.Permissions.Abstractions.Permission.Phone];
                }

                if (status == PermissionStatus.Granted)
                {
                    await BootApplication();
                }
                else if (status != PermissionStatus.Unknown)
                {
                    DialogNotify("Permission Denied", "Can not continue, try again.");
                }
            }
            catch (Exception ex)
            {
                await MetricsManagerHelper.Instance.SendExceptionToApplicationInsightsAsync(ex).ConfigureAwait(true);
            }
        }


        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }

Requests once

The plugin requests the permissions only once. What if the user has denied the permission, changes his mind and would like to grant the permission after all? I can't use this plugin to show the dialog again once the user has denied the permission.

Bug

Version Number of Plugin: 1.1.7
Device Tested On: iPhone SE iOS 9.3
Simulator Tested On: iPhone 6s iOS 9.3

Expected Behavior

Dialog pops up with permission request.

Actual Behavior

Plugin returns with denied.

Steps to reproduce the Behavior

Request location permission after the user has denied the permission.

Feature Request:

Let me override the default so I can ask for the permission a second time.

Photos permissions not working on IOS 7

Bug

Version Number of Plugin: 1.1.7
Device Tested On: iPhone 4 (with iOS 7.1.1 and 7.1.2)
Simulator Tested On: -

Expected Behavior

If permission was granted, PermissionStatus result should be "Granted", otherwise it should ask for permission.

Actual Behavior

PermissionStatus is "Unknow" => no popup asking for permission, application flow is stalled on the request task.

Steps to reproduce the Behavior

Build&Run PermissionSample app on a device with iOS 7 (without granted permissions for the app), click on "Photos"
=> popup : Result "Unknow", click on "Ok"
=> app is stalled, no popup to ask for permissions

Permission plugin not working in Xamarin.Forms project

The Plugin fails in my project. No pompt is displayed when
var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] {Permission.Location});
is run. The permission status can be determined by running

`varstatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);`

If the permission is manually changed in Android's settings the value returned would say granted or denied correctly. However no matter what I do no prompt is showing. No Error message. nothing at all. I made sure to add
```
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grant Results)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}



to MainActiviy in MainActivity.cs

Version Number of Plugin: 1.2.1

Device Tested On:
Samsung galaxy S6 and HTC Nexus 9

I posted a question on[StackOverflow](http://stackoverflow.com/questions/41473975/xamarin-forms-android-permission-prompt-not-displaying) and in the [xamarin forum](https://forums.xamarin.com/discussion/85836/how-to-use-xamarin-forms-maps-in-android-6)
### Expected Behavior
Prompt for permission would show.
### Actual Behavior
No prompt. Things that rely on permission, in this case Xamarin.Forms.Maps throw unhandled exception

App Store submission missing NSUsageDescription without actually requesting those permissions

Hi, we are currently working on a Xamarin.Forms app and have submitted it to the app store for beta testing. It was rejected due to a missing NSCalendarsUsageDescription in the info.plist. The only permission we request is the Location, but no calendar information. Could this be a problem with the Permissions Plugin?

Bug

Version Number of Plugin: 1.2.0-beta9
Device Tested On: iOS10
Simulator Tested On: iOS10

Expected Behavior

It should not be mandatory to set every NSUsageDescription in the info.plist without actually requesting that particular permission.

Actual Behavior

App Store review Team: "This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCalendarsUsageDescription key with a string value explaining to the user how the app uses this data."

Steps to reproduce the Behavior

Submitt an app using the Permissions Plugin

TaskCanceled Exception

Bug Information

I'm seeing a TaskCanceledException when trying to request permissions for Location. I stepped through the code, and what I'm seeing is the following:

RequestPermissionsAsync() the line tcs.Task.ConfigureAwait(false); is causing the code to execute RequestPermissionsAsync again which causes the tcs to get set to null.

Version Number of Plugin: 2.0.1
Device Tested On: Moto G4 16GB running Android 7.0
Simulator Tested On: N/A
Version of VS: Visual Studio for Mac
Version of Xamarin: Xamarin Forms 2.3.4
Versions of other things you are using:

Steps to reproduce the Behavior

Create an Activity, call the await RequestPermissionsAsync(Location).

Expected Behavior

No crash

Actual Behavior

Crash

Code snippet

Screenshots

Android Hang / Cross Permissions

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin: 1.2.1
Device Tested On: Several Android devices
Simulator Tested On:

Expected Behavior

Cross permission will not lock the main thread

Actual Behavior

Cross permission locks the main thread.

Steps to reproduce the Behavior

This problem only replicates in a signed production artifact on android. I am unable to replicate this when publishing directly from visual studio or when pushing a debug artifact. I am not sure what the cause of this can be. The behavior is the app locks up for several seconds ( a minute or two) when requesting permission for the first time.

Here are some logs.


05-13 13:00:38.449 16678-16692/? I/PlayCommon: [14352] com.google.android.play.a.g.a(368): Successfully uploaded logs.
05-13 13:00:38.576 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::CheckAll::31453
05-13 13:00:38.576 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Sms::0
05-13 13:00:38.580 8993-9017/? E/nvaudio_hw: nvaudio_out_set_parameters: Could not find the usecase (0) in the list
05-13 13:00:38.584 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Photos::7
05-13 13:00:38.584 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Camera::0
05-13 13:00:38.598 683-694/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.620 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.620 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Microphone::35
05-13 13:00:38.623 683-1226/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.630 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.630 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Microphone::9
05-13 13:00:38.634 683-1293/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.646 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.646 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Contacts::16
05-13 13:00:38.652 683-1195/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.658 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.658 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Contacts::12
05-13 13:00:38.664 683-898/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.668 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.668 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Storage::9
05-13 13:00:38.671 683-1195/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.674 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.675 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Storage::6
05-13 13:00:38.678 683-694/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.680 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.680 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Speech::5
05-13 13:00:38.683 683-1291/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.686 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.687 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Speech::6
05-13 13:00:38.689 683-1266/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.691 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.691 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Phone::4
05-13 13:00:38.702 683-898/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.708 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.708 2139-2139/? I/mono-stdout: LogController::Time::PermissionService::Check Phone::16
05-13 13:00:38.717 683-694/? I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10994 on display 0
05-13 13:00:38.727 2139-2139/? I/mono-stdout: A task was canceled.
05-13 13:00:38.951 2139-2139/? I/art: Starting a blocking GC Explicit
05-13 13:00:38.967 2139-2139/? I/art: Explicit concurrent mark sweep GC freed 25677(1209KB) AllocSpace objects, 5(432KB) LOS objects, 32% free, 8MB/12MB, paused 314us total 13.765ms
05-13 13:00:38.983 683-692/? I/art: Background sticky concurrent mark sweep GC freed 16150(1007KB) AllocSpace objects, 5(192KB) LOS objects, 5% free, 29MB/31MB, paused 7.618ms total 28.692ms
05-13 13:00:39.224 683-1245/? I/ActivityManager: Process de.codenauts.hockeyapp (pid 31343) has died

of special interest are these lines.
05-13 13:00:38.668 2139-2139/? I/mono-stdout: A task was canceled.

Here is our code


 public static async Task<bool> Check(Permission permission, bool ask = true, bool warn = true)
        {
            LogController.Time("PermissionService::Check " + permission);

            try
            {
                var val = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

                if (val != PermissionStatus.Granted && ask)
                {
                    await CrossPermissions.Current.RequestPermissionsAsync(permission);
                }

                val = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

                if (val != PermissionStatus.Granted && val != PermissionStatus.Unknown && warn)
                {
                    //Notification.Notify(ToastNotificationType.Error, AgLanguage.Error, string.Format(AgLanguage.PermissionError, permission));
                    await UserDialogs.Instance.AlertAsync(AgLanguage.ReConfirmPermissionText, AgLanguage.AgriSync, "Next");
                    await Check(permission, true);
                }
                return val == PermissionStatus.Granted;
            }
            catch (Exception ex)
            {
                LogController.LogError(ex);
            }

            return false;

        }

Is it possible to use without singleton?

Since singleton approach will affect possibilities to do a clean unit test I was wondering if this would just work just injecting IPermissions as a singleton instance on constructor.

Thanks!

Crashes on ios 10

Run the test project on ios 10 with everything up to date. It crashes when you requestpermission.

2016-09-16 02:11:39.560 PermissionsSampleiOS[61455:1589234] critical: 0 PermissionsSampleiOS 0x000000010916474d mono_handle_native_sigsegv + 253
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 1 libsystem_platform.dylib 0x0000000114a2452a _sigtramp + 26
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 2 libsystem_kernel.dylib 0x000000011490b3e0 libsystem_kernel.dylib + 992
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 3 libsystem_c.dylib 0x000000011469eff7 abort + 129
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 4 libsystem_sim_kernel.dylib 0x000000011476f94b __interposition_sim_fallback_abort_with_payload + 0
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 5 libsystem_sim_kernel.dylib 0x000000011476f95a __interposition_sim_fallback_terminate_with_reason + 0
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 6 TCC 0x00000001161aa54b __TCCAccessRequest_block_invoke_2.80 + 0
2016-09-16 02:11:39.561 PermissionsSampleiOS[61455:1589234] critical: 7 TCC 0x00000001161aa473 CRASHING_DUE_TO_PRIVACY_VIOLATION + 0
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 8 TCC 0x00000001161ad6c3 __tccd_send_block_invoke + 268
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 9 libxpc.dylib 0x00000001148c3fc7 _xpc_connection_reply_callout + 45
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 10 libxpc.dylib 0x00000001148bbd1b _xpc_connection_call_reply + 36
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 11 libdispatch.dylib 0x00000001145ad12e _dispatch_client_callout + 8
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 12 libdispatch.dylib 0x000000011459324c _dispatch_queue_override_invoke + 809
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 13 libdispatch.dylib 0x0000000114594a0e _dispatch_root_queue_drain + 506
2016-09-16 02:11:39.562 PermissionsSampleiOS[61455:1589234] critical: 14 libdispatch.dylib 0x00000001145947b4 _dispatch_worker_thread3 + 113
2016-09-16 02:11:39.563 PermissionsSampleiOS[61455:1589234] critical: 15 libsystem_pthread.dylib 0x0000000114a364de _pthread_wqthread + 1129
2016-09-16 02:11:39.563 PermissionsSampleiOS[61455:1589234] critical: 16 libsystem_pthread.dylib 0x0000000114a34341 start_wqthread + 13
#2016-09-16 02:11:39.563 PermissionsSampleiOS[61455:1589234] critical:

Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

Incorrect permission status on Android

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

Version Number of Plugin: 1.1.7
Device Tested On: LG Nexus 5
Simulator Tested On: n/a

Expected Behavior

await CrossPermissions.Current.CheckPermissionStatusAsync(permission); returns PermissionStatus.Denied

Actual Behavior

await CrossPermissions.Current.CheckPermissionStatusAsync(permission); returns PermissionStatus.Granted

Steps to reproduce the Behavior

  1. Start debugging app on device
  2. Grant location permission
  3. Close app
  4. Deny location permission in settings
  5. Start debugging app again
  6. Call await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

RequestPermissionsAsync doesn't show "Permission dialog" for denied permission on iOS

Please fill out either the bug or feature request section and remove whatever section you are not using.

Bug

I have following method for checking permission. We are asking permissions on one page in our app (one-by-one). App uses permissions like camera, calendar, contacts, photos etc. I put a logic to call the following method recursively if the user denied the permission. On Android it works fine meaning it show the "permission" dialog for denied permission, but on iOS it doesn't show the permission dialog. It continuously shows our customised alert dialog.

public static async Task<bool> Check(Permission permission, bool ask = true, bool warn = true)
        {
            var val = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

            if (val != PermissionStatus.Granted && ask)
            {
               // Break point is hitting here, but does not show "permission" dialog again on iOS if user has denied the permission
                await CrossPermissions.Current.RequestPermissionsAsync(permission);
            }

            val = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

            if (val != PermissionStatus.Granted && val != PermissionStatus.Unknown && warn)
            {
                await UserDialogs.Instance.AlertAsync("App will not work properly if you denied the permission.", "Warning", "Next");
		await Check(permission, true);
			}

            return val == PermissionStatus.Granted;
        } 

Version Number of Plugin:1.2.1
Device Tested On: iPhone 6s, 10.2; Android 6/7
Simulator Tested On:

Expected Behavior

It should show "Permission request" dialog every time.

Actual Behavior

Show only first time (clean install). Doesn't show "permission request" dialog again.

Steps to reproduce the Behavior

N/A

Feature Request:

N/A

Update README.MD to discuss iOS 10 changes

I suggest adding an update to the README.md file to let users know that permissions in iOS has changed and developers need to modify the info.plist file to get the plugin to work. A simple link to your blog post New iOS 10 Privacy Permission Settings may be sufficient as it gave me the info I needed when I discovered my app crashing when on RequestPermissionsAsync... and thanks for the plugin.

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.