How to programmatically get the connected device specifically Square Stand using the Square Mobile Payments SDK on iOS.
Currently I’ve code added but it is not functioning. FYI: Square Stand is already connected via USB but in the app in code it is not showing connected through below code. See my code snippet.
let connectedReaders = [ReaderInfo] { MobilePaymentsSDK.shared.readerManager.readers }
if connectedReaders.count > 0 {
if self.isReaderConnected{
if reader.model == .stand {
//We are opening `openCheckoutPage` from here.
}
}
}
FYI: I’ve migrated to Mobile Payment SDK already and I’m using 2.0.0.beta3
version.
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Build on iOS: Point of Sale API
Connect a Contactless Reader
Reader SDK Quickstart
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
To detect if a Square Stand is connected, you need to add specific key-value pairs to your Info.plist file. The Mobile Payments SDK on iOS automatically detects if a Square Stand is connected and uses it to accept swiped credit card payments. However, please note that other than Square Readers, the Mobile Payments SDK cannot interact with any printers, cash drawers, barcode scanners, or other peripherals connected through Square Stand.
This answer was reviewed by @Bryan-Square.
At what point in your code are you using this logic? Is it within a ReaderObserver
? Or right before you call start payment? When do you take a payment currently, is the stand recognized and can you swipe/tap/dip on it?
I’ve added all the required key value pari in info.plist
file.
We are checking it when payment starts. The stand is recognized. We can do the payment. It is only not getting appear on the self.readers
.
Let me share a small video recording I’ve. FYI: Please check the top right corner the battery is charing because stand is connected via USB.
See the screen recording
Please suggest me a good way to accomplish this. Thanks!
extension SquareReaderManager : ReaderObserver {
func readerWasAdded(_ readerInfo: ReaderInfo) {
if readerInfo.model == .stand {
self.isSquareStandConnected = true
}
}
func readerWasRemoved(_ readerInfo: ReaderInfo) {
if readerInfo.model == .stand {
self.isSquareStandConnected = false
}
}
}
So we have added our custom flag in the Observer, But the question is now that if the Square Stand is already connected then will this observer re-call once the app starts?