Git Product home page Git Product logo

permission-please's Introduction

Permission Please V0.9

Request Android runtime permissions from a unity game

This plug-in exists because it wasn't an easy process to use Android runtime permissions and I didn't like it when games would ask for all kind of permissions on app launch.

This plug-in uses base code from the answer on this stackoverflow question by Jason Knight from Noodlecake studios

Getting Started

You can either copy the Plugins directory from this repo into the root of your project or download the provided unity package file PermissionPlease.unitypackage.

Then edit the file AndroidManifest.xml and remove the permissions that you don't need, make sure to only include the ones that you need.

To request a runtime permission on an Android device:

//requests READ_EXTERNAL_STORAGE permission and calls OnPermissionCallback(bool) with the result if it was granted or not, true is supplied to enable logging.
PermissionPlease.GrantPermission(PermissionPlease.AndroidPermission.READ_EXTERNAL_STORAGE, OnPermissionCallback, true);

And OnPermissionCallback would look something like this:

private void OnPermissionCallback(bool granted)
{
    if(granted)
        print("permission granted xD");
    else
        print("permission denied :(");
}

The Java directory is not required in the project, it's just there as a reference. It contains the Java code and a shell script (for my mac) to generate the .jar file.

it can be safely removed from the project but the libs directory is essential.

There are example scenes and codes to try in the project, need to test on an actual Android device [Or Emulator].

Warning

It should work fine, but I haven't tested it a lot, submit any issues you find.

What's next

Detect if user disabled the permission [picked don't ask again] and give an option to open settings to enable the permission

Special Thanks

Noodlecake studios

Author

Jafar Abdulrasoul [Jimmar]

permission-please's People

Contributors

jimmar avatar

Watchers

Willem avatar James Cloos avatar  avatar

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.