Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLVED: authorizeAsync(authCode) crashes iPad, but not simulator. #101

Closed
cezarcarvalhaes opened this issue Nov 16, 2019 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@cezarcarvalhaes
Copy link

cezarcarvalhaes commented Nov 16, 2019

When I run the authorizeAsync method on an iPad, the app crashes and cannot restart. The code runs, as I am able to log the value after the await, however the app crashes (stops and force exits) right after. To run again, it needs to be reinstalled (deleted and rebuilt in xcode). The app only crashes with a valid authcode. Invalid codes return proper error messages and the app continues running fine.

It works as expected in the simulator however.

Device permissions are working fine and handled in previous screens.

To Reproduce

For example -

  1. Connect iPad device to Xcode and build app to that device
  2. Call authorizeAsync(authCode)

Here the piece of code that reproduce the issue.

 import { authorizeAsync } from 'react-native-square-reader-sdk';

  authorizeReader = async (authCode) => {
      try {
          // using a generated mobile auth code for quick start
          const authorizedLocation = await authorizeAsync(authCode);
          console.log(authorizedLocation);
      } catch(error) {
          console.log(error)
      }
  }

Expected behavior

Authorization method resolves and the app continues running.

Environment (please complete the following information):

  • platform: iOS
  • OS and version: target iOS 11.1+
  • dev environment: MacOS 10.15
  • Reader SDK version: 1.3.0

React Native Environment Info:
System:
OS: macOS 10.15
CPU: (4) x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
Memory: 440.02 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.16.1 - ~/.nvm/versions/node/v8.16.1/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8

Device:
iPad Pro (9.7-inch)
iOS 13.2.2

UPDATE:

I added an exception breakpoint, and then called bt after the (lldb) in the console and this is what I got:

* thread #15, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
  * frame #0: 0x000000018285a930 libsystem_kernel.dylib`__abort_with_payload + 8
    frame #1: 0x000000018285ef24 libsystem_kernel.dylib`abort_with_payload_wrapper_internal + 100
    frame #2: 0x000000018285ef54 libsystem_kernel.dylib`abort_with_payload + 12
    frame #3: 0x0000000188c43cc8 TCC`__CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 192
    frame #4: 0x0000000188c43c08 TCC`__TCCAccessRequest_block_invoke.124 + 540
    frame #5: 0x0000000188c47b28 TCC`__tccd_send_message_block_invoke + 256
    frame #6: 0x000000018263cc84 libxpc.dylib`_xpc_connection_reply_callout + 60
    frame #7: 0x0000000182630f18 libxpc.dylib`_xpc_connection_call_reply_async + 76
    frame #8: 0x0000000108cfec58 libdispatch.dylib`_dispatch_client_callout3 + 16
    frame #9: 0x0000000108d1a29c libdispatch.dylib`_dispatch_mach_msg_async_reply_invoke + 388
    frame #10: 0x0000000108d1103c libdispatch.dylib`_dispatch_kevent_worker_thread + 1376
    frame #11: 0x0000000182780fc0 libsystem_pthread.dylib`_pthread_wqthread + 332

Frame 3 says __CRASHING_DUE_TO_PRIVACY_VIOLATION__, however I followed the instructions for updating info.plist. Here's a snippet of what I added for square in case I missed something:

	<key>NSBluetoothPeripheralUsageDescription</key>
	<string>This app integrates with Square for card processing. Square uses Bluetooth to connect your device to compatible hardware.</string>
	<key>NSCalendarsUsageDescription</key>
	<string>Allow Buddy Kiosk2 to access your calendar</string>
	<key>NSCameraUsageDescription</key>
	<string>This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.</string>
	<key>NSContactsUsageDescription</key>
	<string>Allow Buddy Kiosk2 to access your contacts</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>This app integrates with Square for card processing. To protect buyers and sellers, Square requires your location to process payments.</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>This app integrates with Square for card processing. To swipe magnetic cards via the headphone jack, Square requires access to the microphone.</string>
	<key>NSMotionUsageDescription</key>
	<string>Allow Buddy Kiosk2 to access your device's accelerometer</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>Give Buddy Kiosk2 permission to save photos</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>This app integrates with Square for card processing. Upload your account logo, feature photo and product images with the photos stored on your mobile device.</string>
	<key>NSRemindersUsageDescription</key>
	<string>Allow Buddy Kiosk2 to access your reminders</string>
@cezarcarvalhaes cezarcarvalhaes added the bug Something isn't working label Nov 16, 2019
@cezarcarvalhaes
Copy link
Author

After a ton of headbanging, I found the issue. With iOS 13 Apple also requires NSBluetoothAlwaysUsageDescription in addition to NSBluetoothPeripheralUsageDescription. I updated that value and it's working fine now. https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothalwaysusagedescription

I'll submit a pull request to update the getting-started doc.

@cezarcarvalhaes cezarcarvalhaes changed the title authorizeAsync(authCode) crashes iPad, but not simulator. SOLVED: authorizeAsync(authCode) crashes iPad, but not simulator. Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant