Copy text to the clipboard through safari and read the clipboard data in the iOS application

Facing problems with the following scenario. Before posting in stack overflow, I spent several hours on it. Scenario

Step 1: through Safari (or any other browser), the user will view the page (for example, www.abcdef.com), and from this page safari will copy the text to the iOS clipboard (through the user on the touch event on the copy button)

Step 2: the iOS application will be launched and the iOS application will receive / read clipboard data (which was saved / recorded by safari).

Is it possible? and if? If this is not possible, can you share it for this reason?

+5
source share
3 answers

Yes you can do it, here is an example of this

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; if (pasteboard.string != nil) { // Do something with the contents... } 
+5
source

Yes, try checking it out.

 UIPasteboard.general.string 
0
source

I did a similar thing, but for Chrome. You will need 3 components:

  • Browser extension
  • Server Side Handlers
  • iOS app

First you need to create an extension for Safari and, possibly, add a new option to the context menu or in any other accessible way to make it available to the user. Then, when the user selects your custom action, you send the data to your server. The server can then send a notification to your iOS application, and when the user opens the application, he can download recently copied messages.

Of course, when performing all these actions, you should think about creating a user database, authenticate users correctly and protect data transfer.

0
source

Source: https://habr.com/ru/post/1259846/


All Articles