Skip to content
This repository was archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Add rationale stuff to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed May 14, 2019
1 parent 228a08d commit bed9166
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Assent is designed to make Android's runtime permissions easier and take less co
2. [The Basics](#the-basics)
3. [Using Results](#using-results)
4. [Under the Hood Extras](#under-the-hood-extras)
5. [Rationales](#rationales)

---

Expand Down Expand Up @@ -113,3 +114,31 @@ askForPermissions(CALL_PHONE) { _ -> }
```

...Assent would wait until the first permission request is done before executing the second request.

---

## Rationales

Google recommends showing rationales for permissions when it may not be obvious to the user why
you need them.

Assent supports extensible rationale handlers, it comes with two out-of-the-box:
* `SnackBarRationaleHandler`
* `AlertDialogRationaleHandler`

```kotlin
// Could also use createDialogRationale(...) here,
// or provide your own implementation of RationaleHandler.
val rationaleHandler = createSnackBarRationale(rootView) {
onPermission(READ_CONTACTS, "Test rationale #1, please accept!")
onPermission(WRITE_EXTERNAL_STORAGE, "Test rationale #1, please accept!")
onPermission(READ_SMS, "Test rationale #3, please accept!")
}

askForPermissions(
READ_CONTACTS, WRITE_EXTERNAL_STORAGE, READ_SMS,
rationaleHandler = rationaleHandler
) { result ->
// Use result
}
```

0 comments on commit bed9166

Please sign in to comment.