Skip to content

Commit

Permalink
feat: Handle links to OS store's subscriptions
Browse files Browse the repository at this point in the history
The app cannot unsubscribe a plan by itself. The only thing we can do
it to redirect the user to the OS Store's subscriptions page

The Cloudery is expected to do this when the user clicks on the
"Manage plan" button, then the app will intercept the corresponding
link and open the OS page
  • Loading branch information
Ldoppea committed Jan 8, 2024
1 parent ce203d9 commit e0ed08d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/domain/iap/services/clouderyOffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export const interceptNavigation =
(request: WebViewNavigation): boolean => {
log.debug('Navigating to', request.url)
try {
if (isOsStoreUrl(request.url)) {
void Linking.openURL(request.url)
return false
}

if (isStartIapUrl(request.url)) {
const url = new URL(request.url)
const productId = url.searchParams.get('productId')
Expand Down Expand Up @@ -94,6 +99,13 @@ const isStartIapUrl = (url: string): boolean => {
return url.startsWith(START_IAP_URL)
}

const isOsStoreUrl = (url: string): boolean => {
return (
url.startsWith('https://apps.apple.com/account/subscriptions') ||
url.startsWith('https://play.google.com/store/account/subscriptions')
)
}

const buySubscription = async (
itemId: string,
instanceInfo: InstanceInfo,
Expand Down

0 comments on commit e0ed08d

Please sign in to comment.