iOS UIActivity View Controller: Add To Reading Lis

2020-06-16 02:27发布

问题:

Is there a service to be able to add a URL to the iOS Safari's Reading List from in a app.

I would have a url to add and a UIWebView,but I have researched and I can't find anything.

Here is my working UIActivityViewController.

 -(IBAction)actionButton:(id)sender;{
    NSLog(@"shareButton pressed");
    NSURL *URL = [NSURL URLWithString:self.feedItem[@"url"]];//this is your text string

    NSArray *activityItems = @[URL];
    ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init];

    TUSafariActivity *TUSafari = [[TUSafariActivity alloc] init];
    MLCruxActivity *cruxActivity = [[MLCruxActivity alloc] init];

    NSArray *applicationActivities = [NSArray arrayWithObjects:TUSafari,chromeActivity,cruxActivity, nil];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities: applicationActivities];
    activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];

    activityVC.excludedActivityTypes = @[UIActivityTypeAssignToContact];
    [self presentViewController:activityVC animated:TRUE completion:nil];
   }

回答1:

UPDATE: 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");

Currently (iOS SDK 6.1) there is no way to add a item to the Reading List from a third party app.

There are some alternatives like Readability you could use.