How to add an URL to Safari's reading list in

2019-04-08 16:52发布

问题:

In my UIWebView I would like to add an option to add the current page to Safari's reading list. I know this feature exists since GMail offers it when long-pressing a link, yet I can't find any info on what URL scheme to use.

Possible duplicate: How to programmatically access Safari's reading list from iOS

回答1:

iOS 7 added an API to accomplish this:

#import <SafariServices/SafariServices.h>

SSReadingList * readList = [SSReadingList defaultReadingList];
NSError * error = [NSError new];

BOOL status =[readList addReadingListItemWithURL:[NSURL URLWithString:urlToAdd] title:titleToAdd previewText:previewText error:&error];

if(status)
{
        NSLog(@"Added URL");

}
else    NSLog(@"Error");


回答2:

I believe that the action sheet you're seeing in gmail is simply a built-in of UIWebView, inaccessible to developers.