From 35915a54ecbbb5dfb870bc870a05bcef04cb4099 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Wed, 6 Dec 2023 15:21:03 +0100 Subject: [PATCH] feat: Handle links to OS store's subscriptions 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 --- src/app/domain/iap/services/clouderyOffer.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/domain/iap/services/clouderyOffer.ts b/src/app/domain/iap/services/clouderyOffer.ts index 87abf95a2..f68842507 100644 --- a/src/app/domain/iap/services/clouderyOffer.ts +++ b/src/app/domain/iap/services/clouderyOffer.ts @@ -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') ?? 'test_comfort' @@ -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,