3DJakob/react-tinder-card

Cannot copy to clipboard onSwipe

MartinJohannesNilsen opened this issue · 1 comments

Goal: I want to be able to copy to clipboard on swipe.
Problem: As of now, I cannot seem to copy to clipboard on iOS, where I get this error message instead:

message: "The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."
name: "NotAllowedError"

Does anyone have a proposed solution? I have tried multiple npm packages, navigator write and writetext, even simulating button clicks alongside the invisible textarea copy trick. Would love for someone to test it, and potentially give me a way of performing such task. It seems like iOS is stopping it as it does not seem to be a user-instantiated action (although swiping a card is an action a human takes), so maybe a change could be done to the package to make this easier?

Hey! This is not a problem related to react-tinder-card but here is some help:

If you're using react you can use navigator.clipboard.writeText
https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText
Note that as far as I know this is only allowed over HTTPS connections otherwise the browser won't allow you to modify the clipboard this might be why you see that error.

If you're using react-native you can use @react-native-clipboard/clipboard
https://github.com/react-native-clipboard/clipboard
You won't be able to use it within expo go though as it requires linking so you will need to build a development client using EAS build.

Hope that helps!