Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get programmatically the source of the pasteboard content on iOS

On iOS 14, when the user copy/paste content on another app, a notification is displayed with the name of the application where the pasteboard content came from :

On this example, the text is pasted to Notes app from Safari app

Is it possible to get this information programmatically ?

For example, if the user copy a link on Safari and paste it on my app, can the app know the pasteboard content came from Safari ?

I didn't find anything like that on UIPasteboard or UIPasteConfiguration documentation.

like image 597
dgp Avatar asked Nov 07 '22 03:11

dgp


1 Answers

It seems there is no API to get the owner who put the item in pasteboard.

From documentation:

Pasteboard Owner and Items

The object that last put data onto the pasteboard is referred to as the pasteboard owner. Each piece of data placed onto a pasteboard is considered a pasteboard item. The pasteboard can hold single or multiple items. Apps can place or retrieve as many items as they wish. For example, say a user selection in a view contains both text and an image. The pasteboard lets you copy the text and the image to the pasteboard as separate items. An app reading multiple items from a pasteboard can choose to take only those items that it supports (the text, but not the image, for example).

The addItems method, does not have (or maybe I couldn't find it) any property named owner.

like image 53
Gokul Nath KP Avatar answered Nov 15 '22 06:11

Gokul Nath KP