You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Pickup points / Pickup in store](#pickup-points--pickup-in-store)
57
+
-[Geolocation - iOS](#geolocation---ios)
58
+
-[Geolocation - Android](#geolocation---android)
59
+
-[Opting out of the default behavior](#opting-out-of-the-default-behavior)
56
60
-[Contributing](#contributing)
57
61
-[License](#license)
58
62
@@ -144,8 +148,8 @@ function App() {
144
148
}
145
149
```
146
150
147
-
See [Usage with the Storefront API](#usage-with-the-storefront-api) below on how
148
-
to get a checkout URL to pass to the kit.
151
+
See [usage with the Storefront API](#usage-with-the-storefront-api) below for details on how
152
+
to obtain a checkout URL to pass to the kit.
149
153
150
154
> [!NOTE]
151
155
> The recommended usage of the library is through a
@@ -434,9 +438,7 @@ function AppWithContext() {
434
438
435
439
#### Checkout Sheet title
436
440
437
-
There are several ways to change the title of the Checkout Sheet.
438
-
439
-
##### iOS
441
+
##### iOS - Localization
440
442
441
443
On iOS, you can set a localized value on the `title` attribute of the
442
444
configuration.
@@ -447,7 +449,7 @@ following:
447
449
1. Create a `Localizable.xcstrings` file under "ios/{YourApplicationName}"
448
450
2. Add an entry for the key `"shopify_checkout_sheet_title"`
449
451
450
-
##### Android
452
+
##### Android - Localization
451
453
452
454
On Android, you can add a string entry for the key `"checkout_web_view_title"`
453
455
to the "android/app/src/res/values/strings.xml" file for your application.
@@ -742,6 +744,95 @@ public func checkoutDidClickLink(url: URL) {
742
744
}
743
745
```
744
746
747
+
## Pickup points / Pickup in store
748
+
749
+
### Geolocation - iOS
750
+
751
+
Geolocation permission requests are handled out of the box by iOS, provided you've added the required location usage description to your `Info.plist` file:
752
+
753
+
```xml
754
+
<key>NSLocationWhenInUseUsageDescription</key>
755
+
<string>Your location is required to locate pickup points near you.</string>
756
+
```
757
+
758
+
> [!TIP]
759
+
> Consider also adding `NSLocationAlwaysAndWhenInUseUsageDescription` if your app needs background location access for other features.
760
+
761
+
### Geolocation - Android
762
+
763
+
Android differs to iOS in that permission requests must be handled in two places:
764
+
(1) in your `AndroidManifest.xml` and (2) at runtime.
The Checkout Sheet Kit native module will emit a `geolocationRequest` event when the webview requests geolocation
772
+
information. By default, the kit will listen for this event and request access to both coarse and fine access when
773
+
invoked.
774
+
775
+
The geolocation request flow follows this sequence:
776
+
777
+
1. When checkout needs location data (e.g., to show nearby pickup points), it triggers a geolocation request.
778
+
2. The native module emits a `geolocationRequest` event.
779
+
3. If using default behavior, the module automatically handles the Android runtime permission request.
780
+
4. The result is passed back to checkout, which then proceeds to show relevant pickup points if permission was granted.
781
+
782
+
> [!NOTE]
783
+
> If the user denies location permissions, the checkout will still function but will not be able to show nearby pickup points. Users can manually enter their location instead.
784
+
785
+
#### Opting out of the default behavior
786
+
787
+
> [!NOTE]
788
+
> This section is only applicable for Android.
789
+
790
+
In order to opt-out of the default permission handling, you can set `features.handleGeolocationRequests` to `false`
791
+
when you instantiate the `ShopifyCheckoutSheet` class.
792
+
793
+
If you're using the sheet programmatically, you can do so by specifying a `features` object as the second argument:
794
+
795
+
```tsx
796
+
const checkoutSheetKit = new ShopifyCheckoutSheet(config, {handleGeolocationRequests: false});
797
+
```
798
+
799
+
If you're using the context provider, you can pass the same `features` object as a prop to the `ShopifyCheckoutSheetProvider` component:
When opting out, you'll need to implement your own permission handling logic and communicate the result back to the checkout sheet. This can be useful if you want to:
808
+
809
+
- Customize the permission request UI/UX
810
+
- Coordinate location permissions with other app features
811
+
- Implement custom fallback behavior when permissions are denied
812
+
813
+
The steps here to implement your own logic are to:
814
+
815
+
1. Listen for the `geolocationRequest`
816
+
2. Request the desired permissions
817
+
3. Invoke the native callback by calling `initiateGeolocationRequest` with the permission status
Copy file name to clipboardExpand all lines: modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/CustomCheckoutEventProcessor.java
+70-11Lines changed: 70 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,8 @@ of this software and associated documentation files (the "Software"), to deal
25
25
26
26
importandroid.content.Context;
27
27
importandroid.util.Log;
28
+
importandroid.webkit.GeolocationPermissions;
29
+
28
30
importandroidx.annotation.NonNull;
29
31
importandroidx.annotation.Nullable;
30
32
@@ -41,25 +43,70 @@ of this software and associated documentation files (the "Software"), to deal
0 commit comments