React Native Permission rationale not showing - android

I'm having a trouble with react native permission rationale. It is not showing though I already put it in my code.
const rationale = { title: 'Permission', message: 'message' }
const res = await PermissionsAndroid.request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION, rationale);
What is the problem why it's not showing? Thank you for your help.

Late reply, but perhaps this will help someone else who lands here in the future:
I struggled with this as well recently, until I dug into the documentation on PermissionsAndroid:
If rationale is provided, this function checks with the OS whether it is necessary to show a dialog explaining why the permission is needed (https://developer.android.com/training/permissions/requesting.html#explain) and then shows the system permission dialog.
While not immediately clear from that line alone, following the provided link to Google's Documentation yielded this valuable snippet:
If the ContextCompat.checkSelfPermission() method returns PERMISSION_DENIED, call shouldShowRequestPermissionRationale(). If this method returns true, show an educational UI to the user. In this UI, describe why the feature, which the user wants to enable, needs a particular permission.
Essentially, you won't see the rationale on the initial request; it will only be presented after the user has expressly denied the permission (either via the system dialog or through settings). Hope it helps!

Related

MAUI app under Android hot to give write permission to BlazorWebView

I'm developing a MAUI Blazor app that should run under windows and android
On Android I get an error from a component that tries to write on the clipboard
blazor.webview.js:1 Write permission denied.
Reading this doc I cannot figure out where and how to call the BlazorWebViewInizializing event to allow this permission
Or should I do something also in the AndroidManifest.xml?
Thanks
For this, you can check document Permissions.
In android, Permissions must have the matching attributes set in the Android Manifest file. Permission status defaults to Denied.
Above article describes how you can use the .NET Multi-platform App UI (.NET MAUI) Permissions class. This class allows you to check and request permissions at run-time. The Permissions type is available in the Microsoft.Maui.ApplicationModel namespace.
Checking permissions:
To check the current status of a permission, use the Permissions.CheckStatusAsync method along with the specific permission to get the status for. The following example checks the status of the LocationWhenInUse permission:
PermissionStatus status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
Requesting permissions:
To request a permission from the users, use the Permissions.RequestAsync method along with the specific permission to request. If the user previously granted permission, and hasn't revoked it, then this method will return Granted without showing a dialog to the user. The following example requests the LocationWhenInUse permission:
PermissionStatus status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
For more information, you can check document Permissions.

Ho to use Instabug InstabugInvocationEvent.SCREENSHOT without external storage permission?

When I try to setup Instabug bug reporting like this:
BugReporting.setInvocationEvents(
InstabugInvocationEvent.SHAKE,
InstabugInvocationEvent.SCREENSHOT
);
The permission request alert is shown. And I don't understand why. Can't Instabug application use environment folders?
As described in documentation:
Generally, the permission request doesn't appear unless the user attempts to use any of the features requiring the permission. The only exception, if you set the invocation event to be Screenshot. Then, the storage permission will be requested when the application launches.
But is there any way to avoid this?

Handle "dont ask again " Location Permissions Xamarin Forms

I got this dilemma. I am using TK-TORBEN-Maps ,Xamarin Forms. I did implement all the runtime permissions . however, if an user clicks "dont ask me again" what can I do to stop the app from crashing.
I need to let them pass even if they didnt accept and the first page is the map. is there anyway I could still display the map with those permission being denied?
It seems that you could not use the map without the permission.
I think you could explain to your users why the app needs the permission. For example, you could use ShouldShowRequestPermissionRationale.
string permission = Manifest.Permission.AccessFineLocation;
if (ShouldShowRequestPermissionRationale(permission))
{
//Explain to the user why we need to read the contacts
Snackbar.Make(layout, "Location access is required for some reason ", Snackbar.LengthIndefinite)
.SetAction("OK", v => RequestPermissions(PermissionsLocation, RequestLocationId))
.Show();
return;
}
You could refer to this blog for more information.
If you want the app not crash, you could try to navigate to another page after user denies the request.

Android v6 permissions - Asking permission for my SDK

Once again I require your help stackoverflowers!
I've been working on a SDK and now need to verify that the user granted the permissions for stuff like location or file writing.
Verifying is fine, but I think I should ask for the permission if it's needed. The thing is, I have absolutely no access to any activities. I might use the appContext to check for the permissions, but I can't listen to onRequestPermissionsResult like this.
Is there a clever way to ask for permission from my side or should I ask the developers using my SDK to ask the permissions timely so I can use the feature I (and they) need later on?
Thanks for the help!
Personally I'd prefer SDKs to let me as the developer handle when to ask permissions as I may need to give the user some warning, handle it in advance or do other things before prompting them.
If you look at SDKs like Google Play Location services it leaves the handling of the location permissions to the developer and simply adds a warning to the calls that could fail by stating it may throw a SecurityException.
There is also an annotation they use called android.support.annotation.RequiresPermission which you could use to help users of your SDK. Using this annotation will give you the above mentioned Exception warning / error.
Example from official documentation:
#RequiresPermission(anyOf = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION})
public abstract Location getLastKnownLocation(String provider);
And as result
I think that you have to declare permissions into documentation and delegate permission-trouble to your sdk users, because library may be part of Model and it mustn't manipulate with UI (permission dialogs)
You can't call permission dialog without activity

SDK 3.0 reauthorizeForPublish() loses read permissions?

Using the beta 3.0 SDK on Android, I'm opening a Facebook Session with a simple session.openForRead() call with basic permissions (email).
As soon as I want to publish a message on a user's wall I'm re-authorizing the session with session.reauthorizeForPublish() including the new publish permissions (publish_actions) in the ReauthorizeRequest object.
As soon as the last request succeeded, a call to session.getPermissions() only returns the last requested permissions (publish_actions), but loses all of the previous read permissions (email).
The documentation of ReauthorizeRequest's parameter permission clearly states "additional permissions to request", so I'm currently not quite sure why the session loses all the other permissions after a request?
Many thanks,
Alex
Alex, sorry you are running into this. This is a bug in the SDK that we are working on fixing prior to the final release. In the meantime, there are a couple of workaround approaches you could try.
While the Session object's notion of its permissions is out of sync with the Facebook service, the access token associated with the Session still has those permissions and can still be used to make Graph API calls requiring any of the permissions it has been granted (unless the user has subsequently revoked any of them, of course). So if your application logic allows you to disregard the results of the Session.getPermissions() call (for instance, if your UI flow implies the user must have already granted a certain permission prior to reaching a certain step in the flow, so you can assume it is present), you can go ahead and make Graph API calls that require those permissions regardless of what getPermissions says -- real truth about what permissions are associated with the token lives in the service, not in the Session object.
If your app logic is such that you need to check whether a certain permission has been granted, unfortunately right now you may need to keep track of the permissions separately,
perhaps by declaring an ArrayList<String> somewhere that you append the new permissions to, perhaps in your Session.StatusCallback whenever the session is opened, and clear it whenever the session is closed. (You could also make a call to "me/permissions" each time the state transitions to OPENED_TOKEN_UPDATED and store the results.) This should be considered only a temporary workaround until the real fix is available. Hope this helps.

Categories

Resources