restrict airdrop feature for specific app only ios

2019-09-04 19:09发布

I am creating one application using airdrop feature, I want to pass one message(NSString) from one device to other device. I had completed that part, but I want restrict this feature for my application only. Currently what happen, when I am sending NSString via airdrop (let say Device A) in near by device, the other Device B can receive this string even if my application is not installed in it.

My requirement is to share one message from one device to other device only and this thing happen via airdrop for my application only. Please give suggestion. Thanks..!!

1条回答
甜甜的少女心
2楼-- · 2019-09-04 19:21

To ensure that only your app can open this "payload" you must register a new UTI with the system, and supply that same UTI when providing the item to share to UIActivityViewcontroller (using the UIActivityItemSource protocol). The AirDrop sample code has an example of registering a new UTI and using it (see the "Sending/receiving an instance of a custom class as data via AirDrop" parts of the sample)

查看更多
登录 后发表回答