lucasferreira / react-native-android-permissions Goto Github PK
View Code? Open in Web Editor NEWReact Native Android Permissions experimental module - Android M (6.0) permissions like to your React Native application
React Native Android Permissions experimental module - Android M (6.0) permissions like to your React Native application
Would you be interested in a if-needed approach that first runs checkPermission
and then requestPermission
if we don't have it?
requestPermissinonIfNeeded(permissionName)
I don't mind submitting a PR.
When running checkPermissions
inside a HeadlessJS task, it returns
{ [Error: Activity doesn't exist] framesToPop: 1, code: 'E_ACTIVITY_DOES_NOT_EXIST' }
If you use this along with react-native-navigation
, the onRequestPermissionsResult
in MainActivity
never get's called. This is because react-native-navigation
's NavigationActivity
is what get's returned from getCurrentActivity
.
Saw a few crashes on this line specifically. Wondering if this module should take in a context via the constructor or should be using the ReactContext as the context?
int hasPermission = ContextCompat.checkSelfPermission(getCurrentActivity(), permsArray.getString(i));
let pers = ['android.permission.ACCESS_FINE_LOCATION','android.permission.CAMERA']
requestPermission(pers).then((result) => {
console.log("Granted!", result);
// now you can set the listenner to watch the user geo location
}, (result) => {
console.log("Not Granted!");
//this.refs.tvTip.text = ";sfadfaf";
console.log(result);
});
is not work
I get error when run react-native run-android.
:react-native-android-permissions:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). /home/joebiz/Desktop/react_native_app/node_modules/react-native-android-permissions/android/src/main/java/com/burnweb/rnpermissions/RNPermissionsModule.java:44: error: cannot find symbol Context context = getReactApplicationContext(); ^ symbol: class Context location: class RNPermissionsModule 1 error :react-native-android-permissions:compileReleaseJavaWithJavac FAILED
App was working fine, I added android.useAndroidX=true in gradle.properties as few android libraries have migrated to androidX
RNPermissionsModule.java:8: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
tried using import androidx.legacy.app.ActivityCompat, its the same error
React native version : 0.48.0
Hi.
import android.app.Application;
import android.util.Log;
import com.burnweb.rnpermissions.RNPermissionsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNPermissionsPackage()
);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
RNPermissionsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults); // very important event callback
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
I've got some errors with this package in Android Studio on RN 0.29:
error: method does not override or implement a method from a supertype
and
error: cannot find symbol method onRequestPermissionsResult(int,String[],int[])
With RN 0.28 everything works fine.
I think it's because in RN 0.29 there are breaking changes on Android - https://github.com/facebook/react-native/releases/tag/v0.29.0
How to fix my problem?
Despite I do exactly what the documentation prescribes, I'm having an error:
$ react-native run-android --stacktrace
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module RNPermissionsModule : Configuration with name 'default' not found.
What extra should one do to get this issue resolved? Does it look like something generally possible, or is it more likely project-specific?
Hi, is there a way right now to detect if the user has tapped 'never ask again'?
Sam
Since RN 0.29 there's an official module (in NativeModules.AndroidPermissions
) to request permissions in Android Marshmallow, although it is undocumented.
Will be released soon a new documented lib (facebook/react-native#9292).
This module should still be useful to who is using RN <= 0.28 and can't upgrade.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.