expo sample#107
Conversation
Armaxis
left a comment
There was a problem hiding this comment.
🤖 [AI Artem]: Review pass on behalf of Artem — inline comments below, each tagged blocking / important / non-blocking, with a suggested fix where possible.
| | 🔒 Authorizing the SDK | [src/app/permissions.tsx](./src/app/permissions.tsx) | | ||
| | 💰 Taking a Payment | [src/app/index.tsx](./src/app/index.tsx) | | ||
| | ⚙️ Presenting Settings Screen | [src/app/index.tsx](./src/app/index.tsx) | | ||
| | 💳 Presenting MockReaderUI | [src/app/index.tsx](./src/app/index.tsx) | |
There was a problem hiding this comment.
🤖 [AI Artem]: Blocking — these links point to src/app/permissions.tsx / src/app/index.tsx, which don't exist in this example (looks like leftovers from an expo-router layout). The actual files live under src/Screens/.
| | 🔒 Authorizing the SDK | [src/app/permissions.tsx](./src/app/permissions.tsx) | | |
| | 💰 Taking a Payment | [src/app/index.tsx](./src/app/index.tsx) | | |
| | ⚙️ Presenting Settings Screen | [src/app/index.tsx](./src/app/index.tsx) | | |
| | 💳 Presenting MockReaderUI | [src/app/index.tsx](./src/app/index.tsx) | | |
| | 🔒 Authorizing the SDK | [src/Screens/PermissionsScreen.tsx](./src/Screens/PermissionsScreen.tsx) | | |
| | 💰 Taking a Payment | [src/Screens/HomeScreen.tsx](./src/Screens/HomeScreen.tsx) | | |
| | ⚙️ Presenting Settings Screen | [src/Screens/HomeScreen.tsx](./src/Screens/HomeScreen.tsx) | | |
| | 💳 Presenting MockReaderUI | [src/Screens/HomeScreen.tsx](./src/Screens/HomeScreen.tsx) | |
|
|
||
| ```json | ||
| [ | ||
| "../app.plugin.js", |
There was a problem hiding this comment.
🤖 [AI Artem]: Blocking — this snippet doesn't match app.json, which registers the plugin as "./app.plugin.js". Anyone copy-pasting the README snippet gets a broken prebuild (the plugin path would resolve outside the project root).
| "../app.plugin.js", | |
| "./app.plugin.js", |
| "version": "1.0.0", | ||
| "scripts": { | ||
| "start": "expo start", | ||
| "reset-project": "node ./scripts/reset-project.js", |
There was a problem hiding this comment.
🤖 [AI Artem]: Important to fix (quick) — ./scripts/reset-project.js isn't included in this PR, so this script fails for anyone who runs it. Same story for ./assets/images/favicon.png referenced by the web section of app.json (only appIcon.png is checked in). Suggest dropping this script and the web block — or adding the missing files.
| "reset-project": "node ./scripts/reset-project.js", |
| if (modConfig.modResults.language === 'groovy') { | ||
| let contents = modConfig.modResults.contents; | ||
| const mpsdkDep = | ||
| 'implementation("com.squareup.sdk:mobile-payments-sdk:2.5.0")'; |
There was a problem hiding this comment.
🤖 [AI Artem]: Important to fix before merge — this pins the native SDK to 2.5.0, while the RN library declares its own dependency via squareSdkVersion in android/build.gradle. The extra implementation line is needed here (the library uses implementation, not api, so MainApplication.kt can't see MobilePaymentsSdk without it), but on the next SDK bump this will silently drift and the app would compile against a stale native SDK.
Suggest deriving the version from the installed library instead of hardcoding, e.g.:
const libGradle = fs.readFileSync(
require.resolve('mobile-payments-sdk-react-native/android/build.gradle'),
'utf8'
);
const sdkVersion = libGradle.match(/squareSdkVersion = "([^"]+)"/)[1];or, at minimum, add a // keep in sync with android/build.gradle squareSdkVersion comment here and a matching one in the library's build.gradle.
There was a problem hiding this comment.
I removed this dependency in expo example due in sdk now we are changing to api, i tested your suggestion but that it doesnt works
| const kotlinArgs = ` | ||
| tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { | ||
| compilerOptions { | ||
| freeCompilerArgs.add("-Xskip-metadata-version-check") |
There was a problem hiding this comment.
🤖 [AI Artem]: Important to fix before merge — this adds -Xskip-metadata-version-check to every Kotlin compile task in the project to paper over the mismatch between the app's Kotlin 2.1.20 (pinned in app.json) and the library, which is built with Kotlin 2.2.x. That flag is explicitly unsupported by JetBrains: it can turn a compile-time incompatibility into runtime breakage, and it will also mask any future metadata incompatibilities from other libraries.
Suggested fix: bump kotlinVersion to 2.2.x in the expo-build-properties config in app.json and drop this block (see docs/KOTLIN_COMPATIBILITY.md in the repo root for the known RN-gradle-plugin caveats). If 2.2.x genuinely doesn't work with Expo 54's gradle plugin, keep the flag but add a comment explaining why it's needed and when it can be removed.
There was a problem hiding this comment.
we cant bump to kotlin 2.2.x due RN limitation
| }; | ||
|
|
||
| const withSquareMobilePayments = (config, options) => { | ||
| if (!options || !options.applicationId) { |
There was a problem hiding this comment.
🤖 [AI Artem]: Important to fix (quick) — only applicationId is validated. If accessToken/locationId are omitted, prebuild succeeds but the Android buildConfigFields are never generated, so BuildConfig.ACCESS_TOKEN is undefined in PermissionsScreen.tsx and sign-in fails with a confusing error (same for the iOS Info.plist keys). Since this plugin is example-only and the example can't do anything useful without all three, suggest requiring them all:
for (const key of ['applicationId', 'accessToken', 'locationId']) {
if (!options?.[key]) {
throw new Error(
`You must provide '${key}' for the Mobile Payments SDK plugin in app.json`
);
}
}| @@ -0,0 +1,107 @@ | |||
| import { Modal, View, Text, Button, StyleSheet } from 'react-native'; | |||
There was a problem hiding this comment.
🤖 [AI Artem]: Non-blocking, nice to have — TestModal.tsx and SquareLogo.tsx aren't imported anywhere in this example; they're dead files. Suggest deleting both, or wiring TestModal into HomeScreen if it's meant to be used the way the bare example uses it.
| "NSAllowsLocalNetworking": true | ||
| } | ||
| }, | ||
| "bundleIdentifier": "com.anonymous.exampleexpo" |
There was a problem hiding this comment.
🤖 [AI Artem]: Non-blocking, nice to have — com.anonymous.exampleexpo is the default Expo placeholder; a Square sample should ship with a Square-ish identifier.
| "bundleIdentifier": "com.anonymous.exampleexpo" | |
| "bundleIdentifier": "com.squareup.mobilepaymentssdk.exampleexpo" |
(and match it in android.package on line 28).
| activeLabel, | ||
| inactiveLabel = '', | ||
| }: LoadingButtonProps) => { | ||
| console.log(isActive ? activeLabel : inactiveLabel); |
There was a problem hiding this comment.
🤖 [AI Artem]: Non-blocking — a few quirks inherited from the bare example/ app (fine to fix here, or in a follow-up covering both apps):
- this stray
console.logfires on every render; styles.loadingButtonActiveis duplicated in the style array below (it's both the base style and theisActivebranch);HomeScreen.tsxcharges{ amount: 1, currencyCode: CurrencyCode.EUR }(1 euro cent) while the button says "Buy for $1";observeAuthChangesinPermissionsScreen.tsxis declaredasyncbut contains noawait.
There was a problem hiding this comment.
I applied your suggestion changes
This PR create a new example using Expo instead RN pure
This PR also solves this issue
#55