reactjscapacitorurl-scheme

Problems with Capacitor Share Incorrect URL Scheme


I am encountering issues with Capacitor Share on mobile devices in my Ionic/Capacitor application. The problems are as follows:

URL Scheme Issue: When I use window.location.href as the URL parameter for Capacitor.Share.share, the generated URL has a scheme like capacitor:// instead of the expected https://. Is there a way to configure Capacitor to use the correct default URL scheme or a workaround to ensure the correct scheme?

Only solution I see for now it's do it manually like https://' + window.location.host + window.location.pathname

Code sample:

import { Share } from '@capacitor/share'
    
shareData({ title: document.title, url: window.location.href })
    
const shareData = async (data) => {
  try {
    await Share.share(data)
  } catch (error) {
        ...
  }
 }

Solution

  • Is there a way to configure Capacitor to use the correct default URL scheme or a workaround to ensure the correct scheme?

    No, this is not possible on iOS. Yes, you can configure the local scheme on iOS in Capacitor (see docs). But http and https are not allowed according to the Apple Developer docs.