From f843fb6e6fdc3281ed51441f8c00c0b9644261f1 Mon Sep 17 00:00:00 2001 From: Noah Prail Date: Tue, 1 Sep 2020 18:22:48 -0400 Subject: [PATCH] docs(README): Add special instructions for Android setup --- README.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2860c59..e77cdcb 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,7 @@ Follow all Stripe instructions under ["Configure your app"](https://stripe.com/d ### Android -Follow all Stripe instructions under ["Configure your app"](https://stripe.com/docs/terminal/sdk/android#configure). - -Add the plugin to your `MainActivity.java`. +Add the plugin to your `MainActivity.java`: ```java // import it at the top @@ -70,6 +68,36 @@ this.init(savedInstanceState, new ArrayList>() {{ }}); ``` +Add the `ACCESS_FINE_LOCATION`, `BLUETOOTH`, and `BLUETOOTH_ADMIN` permissions to your app's manifest: + +```xml + + + + + + + +``` + +On Android, you must also make sure that Location permission has been granted by the user: + +```javascript +const response = await StripeTerminalPlugin.getPermissions() + +if (!response.granted) { + throw new Error('Location permission is required.') +} + +const terminal = new StripeTerminalPlugin() +``` + +If the user does not grant permission, `StripeTerminalPlugin` will throw an error when you try to initialize it so you will have to handle that. + +_Hint: If the user denies Location permission the first time you ask for it, Android will not display a prompt to the user on subsequent requests for permission and `response.granted` will always be `false`. You will have to ask the user to go into the app's settings to allow Location permission._ + ## Usage ```javascript