You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
In 5.0 it's not possible to ask for multiple permissions at once AND use the new linking stuff.
Please introduce a way to ask multiple permissions.
I created an implementation in my iOS and Android project like this:
Android:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
namespace XXX.Droid.Permissions
{
public class MultiPermissionRequestor : IMultiPermissionRequestor
{
private static FieldInfo fieldAccessor = typeof(BasePermission).GetField("permission", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
public async Task<Dictionary<Type, PermissionStatus>> RequestPermissionsAsync(params BasePermission[] permissions)
{
Dictionary<Permission, Type> mappings = permissions.ToDictionary(p => (Permission)fieldAccessor.GetValue(p), p => p.GetType());
Dictionary<Permission, PermissionStatus> status = await CrossPermissions.Current.RequestPermissionsAsync(mappings.Select(kv => kv.Key).ToArray()).ConfigureAwait(false);
return status.ToDictionary(st => mappings[st.Key], st => st.Value);
}
}
}
iOS:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
namespace XXX.iOS.Permissions
{
public class MultiPermissionRequestor : IMultiPermissionRequestor
{
public async Task<Dictionary<Type, PermissionStatus>> RequestPermissionsAsync(params BasePermission[] permissions)
{
Dictionary<Type, PermissionStatus> result = new Dictionary<Type, PermissionStatus>();
foreach (BasePermission p in permissions)
{
result.Add(p.GetType(), await p.RequestPermissionAsync().ConfigureAwait(false));
}
return result;
}
}
}
This code also makes clear that an extra feature is requested from my side : make BasePermission.Permission a public property instead of a protected field :)
The text was updated successfully, but these errors were encountered:
@jamesmontemagno why would it, what am I missing? it would just be the same as calling permission.RequestPermissionAsync() multiple times in your own code on iOS? But on android it will be able to submit all requests at once, so you get the 1 out 2, 2 out of 2 permission dialog there.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In 5.0 it's not possible to ask for multiple permissions at once AND use the new linking stuff.
Please introduce a way to ask multiple permissions.
I created an implementation in my iOS and Android project like this:
Android:
iOS:
This code also makes clear that an extra feature is requested from my side : make BasePermission.Permission a public property instead of a protected field :)
The text was updated successfully, but these errors were encountered: