Reputation: 711
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 :
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.
Upvotes: 6
Views: 1619
Reputation: 1162
It seems there is no method or property that we can retrieve for UIPasteBoard
Below is the Note from the Apple Documentation
Starting in iOS 14, the system notifies the user when an app gets general pasteboard content that originated in a different app.
They say it is system generated notification. So, I think we can't retrieve the origin app name programmatically.
However, they have provided methods for detecting pattern, but not sure if this will be of any help.
Use the methods described in
Detecting Patterns of Content in Pasteboard Items
to determine if pasteboard items match various patterns, such as web search terms, URLs, or numbers, without notifying the user.
Upvotes: 0
Reputation: 15553
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
.
Upvotes: 1