关键词:自定义分享列表、自定义事件、URL Schemes、UIPasteboard
提前注意:
以免浪费时间,不涉及Share Extension、UIActivityViewController、UIActivity
整体思路
App1:通过URL Schemes+UIPasteboard,分享到App2。
App2:AppDelegate中先跳转到分享VC,然后UIPasteboard获取到分享的数据展示。
效果

001.gif
配置
配置URL Schemes,一个工程可以对应多个,分别用逗号隔开就好。

share01.png
适配iOS10
这里主要是指UIPasteboard变动。最新API已经废除persistent属性,新增UIPasteboardOption。
UIPasteboardOption有两个值:
UIPasteboardOptionExpirationDate:表示到什么时间移除。
UIPasteboardOptionLocalOnly:表示是否一直在本地,相当于之前的persistent属性
最新存储的用法如下:
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"my" create:YES];
if (pasteboard.items.count > 0)
{
pasteboard.items = [NSArray array];
}
NSArray *items = [ShareManager getDataArrFromModel:model Pasteboard:pasteboard];
[pasteboard setItems:items options:@{UIPasteboardOptionLocalOnly:@YES}];
Demo
需要FirstDemo和SecondDemo一起运行,FirstDemo跳转到SecondDemo。欢迎指正!
demo