Skip to content

Commit 67c7678

Browse files
committed
Export types, update README
1 parent a5a3560 commit 67c7678

File tree

4 files changed

+91
-9
lines changed

4 files changed

+91
-9
lines changed

README.md

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ experiences.
3333
- [Colors](#colors)
3434
- [Localization](#localization)
3535
- [Checkout Sheet title](#checkout-sheet-title)
36-
- [iOS](#ios)
37-
- [Android](#android)
36+
- [iOS - Localization](#ios---localization)
37+
- [Android - Localization](#android---localization)
3838
- [Currency](#currency)
3939
- [Language](#language)
4040
- [Preloading](#preloading)
@@ -53,6 +53,10 @@ experiences.
5353
- [Customer Account API](#customer-account-api)
5454
- [Offsite Payments](#offsite-payments)
5555
- [Universal Links - iOS](#universal-links---ios)
56+
- [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)
5660
- [Contributing](#contributing)
5761
- [License](#license)
5862

@@ -434,9 +438,7 @@ function AppWithContext() {
434438

435439
#### Checkout Sheet title
436440

437-
There are several ways to change the title of the Checkout Sheet.
438-
439-
##### iOS
441+
##### iOS - Localization
440442

441443
On iOS, you can set a localized value on the `title` attribute of the
442444
configuration.
@@ -447,7 +449,7 @@ following:
447449
1. Create a `Localizable.xcstrings` file under "ios/{YourApplicationName}"
448450
2. Add an entry for the key `"shopify_checkout_sheet_title"`
449451

450-
##### Android
452+
##### Android - Localization
451453

452454
On Android, you can add a string entry for the key `"checkout_web_view_title"`
453455
to the "android/app/src/res/values/strings.xml" file for your application.
@@ -742,6 +744,72 @@ public func checkoutDidClickLink(url: URL) {
742744
}
743745
```
744746

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.
765+
766+
```xml
767+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
768+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
769+
```
770+
771+
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:
800+
801+
```tsx
802+
<ShopifyCheckoutSheetProvider configuration={config} features={{handleGeolocationRequests: false}}>
803+
{children}
804+
</ShopifyCheckoutSheetProvider>
805+
```
806+
807+
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+
745813
---
746814

747815
## Contributing

modules/@shopify/checkout-sheet-kit/src/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,14 @@ export type CheckoutEvent =
146146
| 'geolocationRequest'
147147
| 'pixel';
148148

149+
export interface GeolocationRequestEvent {
150+
origin: string;
151+
}
152+
149153
export type CloseEventCallback = () => void;
150-
export type GeolocationRequestEventCallback = () => void;
154+
export type GeolocationRequestEventCallback = (
155+
event: GeolocationRequestEvent,
156+
) => void;
151157
export type PixelEventCallback = (event: PixelEvent) => void;
152158
export type CheckoutExceptionCallback = (error: CheckoutException) => void;
153159
export type CheckoutCompletedEventCallback = (

modules/@shopify/checkout-sheet-kit/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import type {
3939
CheckoutEventCallback,
4040
Configuration,
4141
Features,
42+
GeolocationRequestEvent,
4243
Maybe,
4344
ShopifyCheckoutSheetKit,
4445
} from './index.d';
@@ -400,6 +401,8 @@ export type {
400401
CheckoutException,
401402
Configuration,
402403
CustomEvent,
404+
GeolocationRequestEvent,
405+
Features,
403406
PixelEvent,
404407
StandardEvent,
405408
};

sample/src/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ import Icon from 'react-native-vector-icons/Entypo';
3939
import CatalogScreen from './screens/CatalogScreen';
4040
import SettingsScreen from './screens/SettingsScreen';
4141

42-
import type {Configuration} from '@shopify/checkout-sheet-kit';
42+
import type {
43+
Configuration,
44+
GeolocationRequestEvent,
45+
} from '@shopify/checkout-sheet-kit';
4346
import {
4447
ColorScheme,
4548
ShopifyCheckoutSheetProvider,
@@ -342,7 +345,9 @@ function Routes() {
342345
function App() {
343346
return (
344347
<ErrorBoundary>
345-
<ShopifyCheckoutSheetProvider configuration={config}>
348+
<ShopifyCheckoutSheetProvider
349+
configuration={config}
350+
features={{handleGeolocationRequests: true}}>
346351
<AppWithTheme>
347352
<AppWithContext>
348353
<AppWithNavigation>

0 commit comments

Comments
 (0)