0.0.6 • Published 4 years ago
@cashlift_payments/sdk v0.0.6
Support
| version | react-native version | Xcode version |
|---|---|---|
| 3.0.0+ | 0.63.0+ | 12+ |
Installing dependencies into a bare React Native project
$ npm install --save react-native-ble-plx react-native-permissions
# --- or ---
$ yarn add react-native-ble-plx react-native-permissionsSetup
$ npm install --save @diviven/payment
# --- or ---
$ yarn add @diviven/paymentConfiguration & Installation
Expo
- Make sure your Expo project is ejected (formerly: detached). You can read how to do it here and here. (only for expo)
- Follow steps for iOS/Android.
iOS (example setup)
npm install --save react-native-ble-plx- Enter
iosfolder and runpod update - Add
NSBluetoothAlwaysUsageDescriptionininfo.plistfile. (it is a requirement since iOS 13) - If you want to support background mode:
- In your application target go to
Capabilitiestab and enableUses Bluetooth LE AccessoriesinBackground Modessection. - Pass
restoreStateIdentifierandrestoreStateFunctiontoBleManagerconstructor.
- In your application target go to
Android (example setup)
npm install --save react-native-ble-plxIn top level
build.gradlemake sure that min SDK version is at least 18:buildscript { ext { ... minSdkVersion = 21 ...In
build.gradlemake sure to add jitpack repository to known repositories:allprojects { repositories { ... maven { url 'https://www.jitpack.io' } } }(Optional) In
AndroidManifest.xml, add Bluetooth permissions and update<uses-sdk/>:<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Add this line if your application always requires BLE. More info can be found on: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions --> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> ...
Troubleshooting
Problems with Proguard
Add this to your app/proguard-rules.pro
-dontwarn com.polidea.reactnativeble.**🆘 Manual linking
Because this package targets React Native 0.63.0+, you probably won't need to link it manually. Otherwise if it's not the case, follow these additional instructions. You also need to manual link the module on Windows when using React Native Windows prior to 0.63:
iOS
Add this line to your ios/Podfile file, then run pod install.
target 'YourAwesomeProject' do
# …
pod 'RNPermissions', :path => '../node_modules/react-native-permissions'
endAndroid
- Add the following lines to
android/settings.gradle:
include ':react-native-permissions'
project(':react-native-permissions').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-permissions/android')- Add the implementation line to the dependencies in
android/app/build.gradle:
dependencies {
// ...
implementation project(':react-native-permissions')
}How TO use
import {CheckPermissions, StartScanDevices} from '@diviven/payment'
...
CheckPermissions().then(()=>{
StartScanDevices()
.then(devices => {
console.log(devices);
})
.catch(err => {
console.log(err);
});
});