Capacitor: bug: Clipboard API does not work on Safari

Created on 26 Nov 2019  ·  3Comments  ·  Source: ionic-team/capacitor

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 1.3.0

  @capacitor/core: 1.3.0

  @capacitor/android: 1.3.0

  @capacitor/ios: 1.3.0

Installed Dependencies:

  @capacitor/cli 1.3.0

  @capacitor/core 1.3.0

  @capacitor/android 1.3.0

  @capacitor/ios 1.3.0


[fatal] Platform electron is not valid.
[success] Android looking great! 👌
  Found 3 Capacitor plugins for ios:
    cordova-plugin-inappbrowser (3.1.0)
    cordova-plugin-ionic (5.4.5)
    cordova-plugin-whitelist (1.3.4)
[success] iOS looking great! 👌
✨  Done in 8.91s.

Affected Platform(s)

  • [ ] Android
  • [ ] iOS
  • [ ] Electron
  • [x] Web

Current Behavior

When I try to copy text using Clipboard.write({string: value}), it works on Chrome/Firefox/Android/iOS but not Safari.

Non-Error promise rejection captured with value: Clipboard API not available in this browser

Expected Behavior

I expect copying to work in Safari as it does on all other browsers/platforms.

Sample Code or Sample Application Repo

import { Plugins } from '@capacitor/core';
const { Clipboard } = Plugins;

Clipboard.write({ string: "Text To Copy" })

Reproduction Steps

Just try to use the basic Clipboard.write() function in Safari.

Other Technical Details

yarn --version output: 1.19.1

node --version output: v13.1.0

Other Information

Non-Error promise rejection captured with value: Clipboard API not available in this browser

Most helpful comment

The Capacitor Clipboard API (https://capacitor.ionicframework.com/docs/apis/clipboard/) is the one I was talking about, and while it certainly might rely on the browser's Clipboard API, it's not restricted to that. It was my understanding that part of the role of Capacitor was to handle fall-backs for different platforms, and it seems people have had luck with other strategies of implementing copy in Safari that Capacitor could use if needed.

e.g. https://gist.github.com/rproenca/64781c6a1329b48a455b645d361a9aa3

All 3 comments

Capacitor is not magical, if an API is not supported in a browser we can't do anything about it. I think the message is clear enough, Clipboard API not available in Safari. https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API

The Capacitor Clipboard API (https://capacitor.ionicframework.com/docs/apis/clipboard/) is the one I was talking about, and while it certainly might rely on the browser's Clipboard API, it's not restricted to that. It was my understanding that part of the role of Capacitor was to handle fall-backs for different platforms, and it seems people have had luck with other strategies of implementing copy in Safari that Capacitor could use if needed.

e.g. https://gist.github.com/rproenca/64781c6a1329b48a455b645d361a9aa3

We started using capacitor's Clipboard Plugin expecting it to take care of different platforms, adding polyfills if needed. Isn't that the goal of this plugin?

cc @jcesarmobile

Was this page helpful?
0 / 5 - 0 ratings