No se puede recibir Value for Share Extension en chrome

Estoy intentando crear una extensión compartida que funciona bien en Safari Browser , pero no funciona en el browser Chrome .

También hice algunos RND y descubrí que no puedo get valores para Chrome.

Aquí está mi código de file info.plist

<key>NSExtensionAttributes</key> <dict> <key>NSExtensionJavaScriptPreprocessingFile</key> <string>DemoPreprocessor</string> <key>NSExtensionActivationRule</key> <dict> <key>NSExtensionActivationSupportsText</key> <true/> <key>NSExtensionActiovationSupportsWebPageWithMaxCount</key> <integer>1</integer> <key>NSExtensionActivationSupportsWebURLWithMaxCount</key> <integer>1</integer> </dict> 

que permite mostrar mi extensión para el browser Chrome y Safari también.

Y aquí está mi código de file DemoProcessor.js

 var MyPreprocessor = function() {}; MyPreprocessor.prototype = { run: function(arguments) { arguments.completionFunction({"URL": document.URL, "pageSource": document.documentElement.outerHTML, "title": document.title, "selection": window.getSelection().toString()}); } }; var ExtensionPreprocessingJS = new NSItemProvider; 

Y aquí está mi código ShareViewcontroller.m

 #import "ShareViewController.h" #import "MBProgressHUD.h" @import MobileCoreServices; static NSString *const AppGroupId = @"group.tag.ssss7"; @implementation ShareViewController { NSArray *arrayCategory; __weak IBOutlet UITextField *textFieldCategoryName; __weak IBOutlet UIButton *btnPost; __weak IBOutlet UIBarButtonItem *btnCancel; __weak IBOutlet UINavigationItem *nayTitle; __weak IBOutlet UINavigationBar *navBar; } -(void)viewDidLoad { shanetworkingUserDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroupId]; [shanetworkingUserDefaults setObject:@"hello" forKey:@"hello"]; NSString *userId= [shanetworkingUserDefaults objectForKey:@"userId"]; NSLog(@"%@", [[shanetworkingUserDefaults objectForKey:@"categories"] class]); NSError* error; [self didSelectPost]; if (userId==nil || [userId isEqualToString:@""] ) { [self hideBackground]; self.view.hidden= YES; UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"Error" message:@"Please login into ssss" prefernetworkingStyle:UIAlertControllerStyleAlert]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { [self hideExtentionView]; }]; [alert addAction:defaultAction]; [self presentViewController:alert animated:YES completion:nil]; } else { self.view.hidden= NO; id jsonObject = [NSJSONSerialization JSONObjectWithData:[shanetworkingUserDefaults objectForKey:@"categories"] options: NSJSONReadingMutableContainers error:&error]; arrayCategory= [NSArray arrayWithArray:jsonObject]; NSLog(@"%@", [arrayCategory class]); NSMutableArray *cityArray = [[NSMutableArray alloc] init]; NSMutableArray *testFeeds = [NSJSONSerialization JSONObjectWithData: [shanetworkingUserDefaults objectForKey:@"categories"] options:NSJSONReadingMutableContainers error:nil]; [cityArray addObjectsFromArray:testFeeds]; NSLog(@"%lu", (unsigned long)[cityArray count]); // [self.tableViewssss reloadData]; // here you must have to provide your app group id that you already created } } -(void) hideBackground { [self.view setBackgroundColor:[UIColor clearColor]]; [self.tableViewssss setBackgroundColor:[UIColor clearColor]]; [textFieldCategoryName setBackgroundColor:[UIColor clearColor]]; [nayTitle setTitle:@""]; [btnPost setHidden:YES]; [navBar setHidden:YES]; } - (BOOL)isContentValid { // Do validation of contentText and/or NSExtensionContext attachments here return YES; } - (void)didSelectPost { // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. inputItem = self.extensionContext.inputItems.firstObject; NSItemProvider *urlItemProvider = [[inputItem.userInfo valueForKey:NSExtensionItemAttachmentsKey] objectAtIndex:0]; if ([urlItemProvider hasItemConformingToTypeIdentifier:(__bridge NSString *)kUTTypeURL]) { [urlItemProvider loadItemForTypeIdentifier:(__bridge NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *url, NSError *error) { if (error) { NSLog(@"Error occunetworking"); } else { if ([shanetworkingUserDefaults objectForKey:@"userId"]==nil) { UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"Error" message:@"You must be logged In to share" prefernetworkingStyle:UIAlertControllerStyleAlert]; UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:ok]; [self presentViewController:alert animated:YES completion:nil]; return; } NSMutableArray *previousUrlsArray = [[NSMutableArray alloc]initWithArray:[shanetworkingUserDefaults objectForKey:@"urlsArray"]]; if (previousUrlsArray==nil) { previousUrlsArray =[[NSMutableArray alloc]init]; } [previousUrlsArray addObject:url.absoluteString]; NSMutableDictionary *dict= [[NSMutableDictionary alloc]init]; [dict setObject:previousUrlsArray forKey:@"urls"]; [shanetworkingUserDefaults setObject:dict forKey:@"urlsDictionary"]; [shanetworkingUserDefaults setObject:previousUrlsArray forKey:@"urlsArray"]; // [shanetworkingUserDefaults synchronize]; [shanetworkingUserDefaults setObject:url.absoluteString forKey:@"siteURL"]; [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@",url.absoluteString] forKey:@"sURL"]; NSLog(@"%@",[shanetworkingUserDefaults objectForKey:@"sURL"]); // NSMutableArray *arrSites; // if ([shanetworkingUserDefaults valueForKey:@"ShanetworkingExtension"]) // arrSites = [shanetworkingUserDefaults valueForKey:@"ShanetworkingExtension"]; // else // arrSites = [[NSMutableArray alloc] init]; // NSDictionary *dictSite = [NSDictionary dictionaryWithObjectsAndKeys:self.contentText, @"Text", url.absoluteString, @"URL",nil]; // [arrSites addObject:dictSite]; // [shanetworkingUserDefaults setObject:arrSites forKey:@"ShanetworkingExtension"]; // [shanetworkingUserDefaults synchronize]; // UIAlertController * alert= [UIAlertController // alertControllerWithTitle:@"Success" // message:@"Posted Successfully." // prefernetworkingStyle:UIAlertControllerStyleAlert]; // // UIAlertAction* ok = [UIAlertAction // actionWithTitle:@"OK" // style:UIAlertActionStyleDefault // handler:^(UIAlertAction * action) // { // [UIView animateWithDuration:0.20 animations:^ // { // self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height); // } // completion:^(BOOL finished) // { // [self.extensionContext completeRequestReturningItems:nil completionHandler:nil]; // }]; // }]; // // [alert addAction:ok]; // [self presentViewController:alert animated:YES completion:nil]; } }]; } } - (NSArray *)configurationItems { // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. return @[]; } -(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; /* * If the cell is nil it means no cell was available for reuse and that we should * create a new one. */ if (cell == nil) { /* * Actually create a new cell (with an identifier so that it can be dequeued). */ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"] ; cell.selectionStyle = UITableViewCellSelectionStyleDefault; } cell.textLabel.text=[[arrayCategory objectAtIndex:indexPath.row] valueForKey:@"category_name"]; return cell; } -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [arrayCategory count]; } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self saveInUserDefaultsWithCategoryName:[[arrayCategory objectAtIndex:indexPath.row] valueForKey:@"category_name"] andId:[[[arrayCategory objectAtIndex:indexPath.row] valueForKey:@"id"] integerValue]]; } - (IBAction)postBtnTapped:(id)sender { [self saveInUserDefaultsWithCategoryName:textFieldCategoryName.text andId:-1]; } -(void) saveInUserDefaultsWithCategoryName : (NSString*) categoryName andId : (NSInteger) categoryId { NSString *stringId=[shanetworkingUserDefaults objectForKey:@"id"]; ([stringId length]>0) ? [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@,%ld",stringId, (long)categoryId] forKey:@"id"] : [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%ld", (long)categoryId] forKey:@"id"]; NSLog(@"%@", [shanetworkingUserDefaults objectForKey:@"id"]); NSString *stringCategoryName=[shanetworkingUserDefaults objectForKey:@"category_name"]; ([stringCategoryName length]>0) ? [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@,%@",stringCategoryName, categoryName] forKey:@"category_name"] : [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@",categoryName] forKey:@"category_name"]; NSLog(@"%@", [shanetworkingUserDefaults objectForKey:@"category_name"]); NSString *stringURL=[shanetworkingUserDefaults objectForKey:@"URL"]; ([stringURL length]>0) ? [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@,%@",stringURL, [shanetworkingUserDefaults objectForKey:@"sURL"]] forKey:@"URL"] : [shanetworkingUserDefaults setObject:[NSString stringWithFormat:@"%@",[shanetworkingUserDefaults objectForKey:@"sURL"]] forKey:@"URL"]; NSLog(@"%@", [shanetworkingUserDefaults objectForKey:@"URL"]); NSDictionary *categoryDictionary = [NSDictionary dictionaryWithObjectsAndKeys:categoryName,@"categoryName", nil]; NSArray *categoryArray = [NSArray arrayWithObject:categoryDictionary]; NSMutableDictionary *mainDictionary = [[NSMutableDictionary alloc]init]; [mainDictionary setObject:categoryArray forKey:@"categories"]; [mainDictionary setObject:@"0" forKey:@"categoryType"]; [mainDictionary setObject:[shanetworkingUserDefaults objectForKey:@"siteURL"] forKey:@"url"]; [mainDictionary setObject:[shanetworkingUserDefaults objectForKey:@"access_token"] forKey:@"access_token"]; AppServices *appServices = [AppServices shanetworkingInstance]; appServices.delegate = self; [appServices postCategoriesOnServer:mainDictionary withSucessBlock:nil withfailureBlock:nil]; UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Please choose hit a category or create a new one " message:@"" prefernetworkingStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:nil]; [alert addAction:okAction]; [self presentViewController:alert animated:YES completion:nil]; [MBProgressHUD showHUDAddedTo:self.view animated:YES]; // [self enableUserInteraction:NO]; // [[AppServices shanetworkingInstance] sendData:nil withSucessBlock:nil withfailureBlock:nil]; // [shanetworkingUserDefaults setObject:[NSNumber numberWithInteger:categoryId] forKey:@"id"]; // [shanetworkingUserDefaults setObject:categoryName forKey:@"category_name"]; // NSMutableDictionary *dict=[[NSMutableDictionary alloc] init]; // // [dict setObject:categoryName forKey:@"category_name"]; // [dict setObject:[NSNumber numberWithInteger:categoryId] forKey:@"id"]; // NSLog(@"%@", [shanetworkingUserDefaults objectForKey:@"siteURL"]); // // [dict setObject:[shanetworkingUserDefaults objectForKey:@"siteURL"] forKey:@"siteurl"]; // // // [shanetworkingUserDefaults setObject:[self dictToJson:dict] forKey:@"categorydictionary"]; } -(NSString *)dictToJson:(NSDictionary *)dict { NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject: dict options:(NSJSONWritingOptions) (/* DISABLES CODE */ (YES) ? NSJSONReadingMutableContainers : 0) error:&error]; if (! jsonData) { NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription); return @"{}"; } else { return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } } - (IBAction)cancelBtnTapped:(id)sender { [self hideExtentionView]; } -(void) hideExtentionView { [self.extensionContext completeRequestReturningItems: nil completionHandler: nil]; } -(void) showAlertViewWithMessage:(NSString *)message { UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:message prefernetworkingStyle:UIAlertControllerStyleAlert]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { [self hideExtentionView]; }]; [alert addAction:defaultAction]; [self presentViewController:alert animated:YES completion:nil]; } -(void)enableUserInteraction:(BOOL)enable { [self.view setUserInteractionEnabled:enable]; } #pragma mark- AppServicesDelegate methods -(void)showMessage:(NSString *)message { [MBProgressHUD hideHUDForView:self.view animated:YES]; // [self enableUserInteraction:YES]; [self showAlertViewWithMessage:message]; } @end 

Ahora el problema es que en el código anterior, esta function está funcionando

  -(void) saveInUserDefaultsWithCategoryName : (NSString*) categoryName andId : (NSInteger) categoryId { **// not getting values for chrome, but for Safari i am getting** }