Comments (14)
I believe those changes might fix the issue on Android 12
https://github.com/stripe/stripe-terminal-react-native/pull/56/files#diff-ed8534ece8080a880075e103269eb1b9bdff22e8dfcf8427d7d977603292b889R7
from stripe-terminal-react-native.
To be clear, this happens at the time of connect to a BT reader.
In addition to app checks, I tried adding
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
As is used in the example app with no change in behavior.
from stripe-terminal-react-native.
Can we also clean up the guidance or just provide a utility in the SDK that handles this? We should make it clear and easy for users to be able to write an app that can work on either platform and currently the android checks need a guard around them to not execute on iOS
from stripe-terminal-react-native.
chatting with @dhenry-stripe we may need to upgrade the android SDK here to one that uses a version of the bbpos SDK that supports android 12
from stripe-terminal-react-native.
@jdivock-stripe to clarify, didn't you make it work yet right? And you are facing the same issue in the example app?
I've covered this case in the README file https://github.com/stripe/stripe-terminal-react-native#android-1 and actually this code snippet should do the trick. If it's not, I need to investigate it again.
from stripe-terminal-react-native.
The guidance in the doc does not work as described, as mentioned in the comment above it may just be a matter of upgrading the underlying android SDK
from stripe-terminal-react-native.
@jdivock-stripe I've initialized new react native project (cli) and just installed stripe-terminal-react-native library. I haven't encountered any issue regarding permissions, this is the full code that I used to make it works:
import React, {useEffect, useState} from 'react';
import {
Alert,
PermissionsAndroid,
Platform,
ScrollView,
Text,
TouchableOpacity,
View,
} from 'react-native';
import {
connectBluetoothReader,
Reader,
StripeTerminalProvider,
useStripeTerminal,
} from 'stripe-terminal-react-native';
const App = () => {
const [permissionsGranted, setPermissionsGranted] = useState(false);
const [discovered, setDiscovered] = useState<Reader.Type[]>([]);
const [connected, setConnected] = useState<Reader.Type>([]);
const fetchTokenProvider = async () => {
const response = await fetch('http://10.0.2.2:3002/connection_token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
const {secret} = await response.json();
return secret;
};
const style = {
flex: 1,
height: 800,
};
useEffect(() => {
async function init() {
try {
const granted = await PermissionsAndroid.request(
'android.permission.ACCESS_FINE_LOCATION',
{
title: 'Location Permission Permission',
message: 'App needs access to your Location ',
buttonPositive: 'Agree',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('You can use the Location');
setPermissionsGranted(true);
} else {
Alert.alert(
'Location services are required in order to connect to a reader.',
);
}
} catch {
Alert.alert(
'Location services are required in order to connect to a reader.',
);
}
}
if (Platform.OS === 'android') {
init();
} else {
setPermissionsGranted(true);
}
}, []);
const {discoverReaders} = useStripeTerminal({
onFinishDiscoveringReaders: finishError => {
console.log('finishError', finishError);
},
onUpdateDiscoveredReaders: readers => {
console.log('readers', readers);
setDiscovered(readers);
},
});
const handleConnect = async () => {
const {reader, error} = await connectBluetoothReader({
readerId: discovered[0].serialNumber,
// locationId: selectedLocation?.id,
});
if (reader) {
setConnected(reader);
}
};
const handleDiscover = async () => {
const {error} = await discoverReaders({
discoveryMethod: 'bluetoothScan',
simulated: true,
});
console.log('error', error);
};
return (
<ScrollView contentContainerStyle={style}>
{permissionsGranted && (
<StripeTerminalProvider tokenProvider={fetchTokenProvider}>
<>
<TouchableOpacity
style={{backgroundColor: '#dffaaa', width: 150, height: 45}}
onPress={handleDiscover}>
<Text>discoveredReaders</Text>
</TouchableOpacity>
{discovered.map(reader => (
<View style={{height: 30}}>
<Text>{reader.serialNumber}</Text>
</View>
))}
{discovered.length > 0 && (
<TouchableOpacity
style={{backgroundColor: '#dffaaa', width: 150, height: 45}}
onPress={handleConnect}>
<Text>Connect via bluetooth</Text>
</TouchableOpacity>
)}
{connected && (
<View style={{height: 30}}>
<Text>Connected reader:</Text>
<Text>{connected.serialNumber}</Text>
</View>
)}
</>
</StripeTerminalProvider>
)}
</ScrollView>
);
};
export default App;
from stripe-terminal-react-native.
does it happen in simulated mode or only with physical readers?
from stripe-terminal-react-native.
terminal-permissions.mov
from stripe-terminal-react-native.
The example app crashes out immediately upon load on my Pixel 5a (android 12) my emulator loads, but that's a pixel 5 on android 11… setting up an AVD with 12 now to try to confirm. As stated earlier in the thread I think we're aware of BT changes in android 12 and it's my understanding we'll probably have to update the underlying terminal android sdk to resolve
from stripe-terminal-react-native.
Confirmed on the emulator as well, logged #57
from stripe-terminal-react-native.
also upgraded Android SDK version
from stripe-terminal-react-native.
@jdivock-stripe please let us know after you run Arek's code on the emulator if you still get the errors.
from stripe-terminal-react-native.
branch still crashes out on app load, hardware device isn't needed to repro as this is reproducible with an emulated Pixel 5 on android 12
logcat here:
https://gist.github.com/jdivock-stripe/2b248ae192a1772990fb2452f1821e4e
from stripe-terminal-react-native.
Related Issues (20)
- Unexpected layout rotation at tap-to-pay screen when calling collectPaymentMethod HOT 2
- If reader remains connected, payment cannot be processed due to expired connection token HOT 8
- [test]
- device does not use trusted execution HOT 2
- Request: Expose SDK state machines
- collectPaymentMethod
- Likely date of next release? HOT 1
- Android build failure: EXPO 49 + 0.0.1-beta.14 HOT 7
- Bug: DiscoverReaders Method Incorrectly Shows Battery Level as 0 for Discovered Readers HOT 3
- Issue with Implementing "Tap to Pay" using Stripe Terminal in React Native App HOT 10
- Mismatch between documentation and types file when calling createSetupIntent
- When creating a new react native project and adding the sdk, it fails to build. HOT 11
- Error: Operation not permitted. Verify the app has the necessary entitlements and that the application bundle is valid. HOT 4
- Can't reconnect local reader on iOS when going background on enter pin screen HOT 3
- Linking account on iOS HOT 3
- Setup intents are not available with Tap to Pay on Android HOT 1
- When calling collectPaymentMethod, the tuple returned is {undefined, undefined}. HOT 1
- When starting a payment using simulated reader, an expired API key is thrown HOT 6
- Android client and server-side payment intent creation fails HOT 4
- MEtadata not being sent to payment intent HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stripe-terminal-react-native.