Skip to content

Commit 4d356fd

Browse files
authored
fix(square-mobile-payments): fix Android SDK initialization, main thread dispatch, and NPE (#789)
1 parent 8bae7e4 commit 4d356fd

File tree

3 files changed

+217
-108
lines changed

3 files changed

+217
-108
lines changed

.changeset/lovely-cloths-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@capawesome/capacitor-square-mobile-payments': patch
3+
---
4+
5+
fix: Android SDK initialization, main thread dispatch, and NPE

packages/square-mobile-payments/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,38 @@ npx cap sync
4040

4141
### Android
4242

43+
#### SDK Initialization
44+
45+
The Square Mobile Payments SDK must be initialized in your `Application` class before using the plugin. Create a custom `Application` class (if you don't already have one) and add the following code:
46+
47+
1. Create a file `MainApplication.java` in your app's `android/app/src/main/java/<your-package>/` directory:
48+
49+
```java
50+
package com.example.app;
51+
52+
import android.app.Application;
53+
import com.squareup.sdk.mobilepayments.MobilePaymentsSdk;
54+
55+
public class MainApplication extends Application {
56+
57+
@Override
58+
public void onCreate() {
59+
super.onCreate();
60+
MobilePaymentsSdk.initialize("YOUR_SQUARE_APPLICATION_ID", this);
61+
}
62+
}
63+
```
64+
65+
**Note**: Replace `YOUR_SQUARE_APPLICATION_ID` with your actual Square Application ID.
66+
67+
2. Register the custom `Application` class in your `AndroidManifest.xml`:
68+
69+
```xml
70+
<application
71+
android:name=".MainApplication"
72+
...>
73+
```
74+
4375
#### Variables
4476

4577
If needed, you can define the following project variable in your app's `variables.gradle` file to change the default version of the dependency:

0 commit comments

Comments
 (0)