Rectangle 27 3

It turns out that I was missing a return self.url; ...

- (id)item {
    NSString *activityType = self.activityType;

    if ([self.placeholderItem isKindOfClass:[NSString class]]) {

        if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {

            self.url = kSHARELINK_FB;

        } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {

            self.url = kSHARELINK_TWITTER;


        } else if ([activityType isEqualToString:UIActivityTypeMessage]) {

            self.url = kSHARELINK_SMS;


            } else if([activityType isEqualToString:UIActivityTypeMail]){
            self.url = kSHARELINK_EMAIL;


        }else if ([activityType isEqualToString:UIActivityTypePostToWeibo]){
            self.url = kSHARELINK_WEIBO;

        }else{

            self.url = kSHARELINK_OTHER;

        }
      return self.url;
    }

    return self.placeholderItem;
}

ios - how to share different urls via uiactivityviewcontroller? - Stac...

ios xcode share analytics uiactivityviewcontroller
Rectangle 27 19

So basically, you want to share an image via Facebook or Whatsapp, plus provide an option to save the image.

Well... Lets break this down slowly for the 2 quickest ways.

If you share image via UIActivityViewController then in order to provide Whatsapp option, you'll need to create a custom UIActivity (See Stackoverflow Question).

  • Whatsapp has not provided a URL scheme to pass an image object (yet).Look at JBWhatsAppActivity if you're curious about this in general.

If you share image via UIDocumentInteractionController then in order to provide the Facebook option, you'll need to specify the UTI as public.image.

  • The public.image UTI will populate your UIDocumentInteractionController with alot more options than just Facebook and Whatsapp.
Save
-presentOpenInMenuFromRect:inView:animated:
  • You will need to use -presentOptionsMenuFromRect:inView:animated: method in order to show the option Save to Album. But this will include other options such as Mail etc.
UIDocumentInteractionController

If you use UIActivityViewController and don't want to create a custom UIActivity for Whatsapp, then you're stuck but... if you decide to use a custom UIActivity then you're still stuck because there's no provision to share an image object with Whatsapp using UIActivityViewController.

The thing that complicates it is Whatsapp which forces you to use UIDocumentInteractionController which seems like the only way to share an image on Whatsapp (currently) and due to it's limited URL scheme, there's no point providing it in UIActivityViewController.

Furthermore, using UIDocumentInteractionController in turns leads you to provide more options than you would want.

So I will leave the app just as it is, it works fine sharing for whatsapp, but not the way I wanted. Anyway, thanks for solving my doubt!

@LucasDomene : you're welcome :) well... right now i see no other way around it so you're better off the way you are.

ios - Sharing image to Whatsapp & Facebook - Stack Overflow

ios objective-c uiactivityviewcontroller whatsapp uidocumentinteraction
Rectangle 27 40

Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.

Seems they would prefer devs to use the SDK:

While you can use the iOS native view controller API (share sheet) directly, there are several reasons to use the native iOS Share dialog provided by the Facebook SDK. Using the native Share dialog provides a quick way to test that people have signed into Facebook on their iOS 6+ devices. This API also uses the same style block as other parts of the Facebook SDK.

That makes the facebook share even less useful than before imho ...

It is the same policy that have been using android years

It would help if the Facebook API was even functional and if they had any support when it's not.

At least the sign in works...

objective c - UIActivityViewController for Facebook not Showing Defaul...

objective-c xcode facebook uiactivityviewcontroller
Rectangle 27 8

is a HTML4 entity and it will convert itself to a symbol in an email if you share it as plain text.

Convert the string to a URL instead:

if let url = URL(string: "http://preprodgo.travelstart.com/search-on-index?version=3&timestamp=2017-09-15_10-31-27-031") {
    let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
    present(activityViewController, animated: true)
}

Thanks! And what I actually wanted to share is this: ``` message = String(format: NSLocalizedString("share_text_search_result_multi_city", comment: "Hey,\nI found great flights on Flapp from %1$@ from only %2$@ %3$d.\nCheck them out!\n\n%4$@"), String(describing: outboundAirportCityName), cheapestPriceCurrencyText, cheapestPrice, link) ``` Any idea for preventing convertion if I have to share it as plain text?

Include the strting and the URL as two separate activity items. That way, the URL will not be converted.

not working. It's still converted.

ios - Looks like Apple converts strings incorrectly in UIActivityViewC...

ios swift url uiactivityviewcontroller
Rectangle 27 3

Flickr share with UIActivityViewController will only work if you are sharing a image. So in your array with activity items there should be at least one image.

Make sure that the image is of type UIImage:

NSArray *shareItems = @[someImage, @"Text of the messages"];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];

Thanks, I can confirm that I am sharing an image. The image shares in mail, Airdrop, Facebook, Twitter, and Message. One thing I tried was having only an image in the shareItems array but it made no difference.

Weird, I'm also sharing an UIImage with title in one of my apps and it works just a expected.

OK that is helpful. You are the first person that confirmed that it should work. I will try a different device with a different Flickr account.

I got it working. I was including a URL in the shareItems along with the image which causes the icon not to display. I must have done the test of attempting to share only an image wrong because sharing only an image is possible and displays the Flickr icon. I still can not get the RDActivityViewController implementation to display the Flickr icon. Have you ever used that class.

ios - UIActivityViewController Flickr Sharing - No Flickr option appea...

ios ios7 flickr uiactivityviewcontroller
Rectangle 27 4

Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app. Seems they would prefer devs to use the SDK:

While you can use the iOS native view controller API (share sheet) directly, there are several reasons to use the native iOS Share dialog provided by the Facebook SDK. Using the native Share dialog provides a quick way to test that people have signed into Facebook on their iOS 6+ devices. This API also uses the same style block as other parts of the Facebook SDK.

ios - UIActivityViewController Facebook share text - Stack Overflow

ios iphone facebook twitter uiactivityviewcontroller
Rectangle 27 25

You can use it like this to reduce your length of podfile and would also be able to maintain code once!!!

xcodeproj 'Demo.xcodeproj'

platform :ios, "6.0"

def common_pods_for_target
    pod 'AA', '0.0.1'
    pod 'BB', '0.0.1'
    pod 'CC', '0.0.1'
    pod 'DD', '0.0.1'
    pod 'EE', '0.0.1'
    pod 'FF', '0.0.1'
    pod 'GG', '0.0.1'
end

target "Demo" do
    pod 'Demo-A', '3.1.1'
    pod 'Demo-B', '1.0'
    pod 'Demo-C', '~> 1.9.0'
    pod 'Demo-D', '~> 1.1'
    common_pods_for_target
end

target "DemoTests" do
    pod 'DemoTests-X', '3.1.1'
    pod 'DemoTests-Y', '0.4.0'
    pod 'DemoTests-Z', '4.1.1'
    common_pods_for_target
end

target "DemoWidget" do
    pod 'DemoWidget-1', '3.1.1'
    pod 'DemoWidget-2', '0.4.0'
    pod 'DemoWidget-3', '4.1.1'
end

Just define all your common pods in a variable and use it in the targets you want.

Notice, that apparently you should use lowercase for the first letter.

ios - how to share the some pods in two target by podfile - Stack Over...

ios objective-c iphone cocoapods xctest
Rectangle 27 7

CocoaPods now recommends using an abstract_target if you want multiple targets to share the same pods. Notice how the actual targets are nested under the new abstract one.

# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
  pod 'ShowsKit'
  pod 'Fabric'

  # Has its own copy of ShowsKit + ShowWebAuth
  target 'ShowsiOS' do
    pod 'ShowWebAuth'
  end

  # Has its own copy of ShowsKit + ShowTVAuth
  target 'ShowsTV' do
    pod 'ShowTVAuth'
  end
end

Is Shows one of the targets name? So there are three targets, Shows, ShowsiOS and ShowsTV

@malhobayyeb only two targets, ShowsiOS and ShowsTV. The Shows "target" is abstract - it doesn't actually exist.

ios - how to share the some pods in two target by podfile - Stack Over...

ios objective-c iphone cocoapods xctest
Rectangle 27 3

Thread safety refers to the ability to change in-memory data structures from one thread in a way that doesn't damage the ability of other threads to also view or change those structures. When you use NSUserDefaults to share data between an app extension and its containing app, you're not sharing in-memory data between multiple threads, you're sharing on-disk data between multiple processes, so discussions of thread safety do not apply.

The documentation for NSUserDefaults synchronize doesn't say for sure, but one can almost certainly assume that it uses an atomic file write that is, there's no danger of one process reading a file that's been partially written by another process. If you're concerned about race conditions or other timing issues between when your app writes defaults and your extension reads them (or vice versa), just be sure to synchronize immediately after important writes and immediately before important reads.

The comment about data corruption applies to plain file read/write operations naively reading or writing a file in two processes can result in data corruption, because one process might read a partially written file or partially overwrite file contents. If you're doing your own file I/O directly, you need some sort of coordination mechanism (like NSFileCoordinator, but beware that only works correctly between iOS apps/extensions in iOS 8.2 and newer). Or you can use higher level utilities that do their own coordination, like CFPreferences/NSUserDefaults, SQLite, Core Data, or Posix file locks.

TLDR: Yes, you can safely use NSUserDefaults to share between an extension and its containing app. Just follow the recommendations in Apple's app extensions guide.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

multithreading - Is NSUserDefaults thread safe for sharing data betwee...

ios multithreading shared ios-app-group
Rectangle 27 2

You can't share image and text both in WhatsApp using UIActivityViewController. Only single thing you can post. That is image or text.

Any option to share both image and text , I want to share both image and text

objective c - iOS sharing image and URL to whatsapp using UIActivityVi...

ios objective-c uiactivityviewcontroller
Rectangle 27 1

Starting from iOS 6, you can use UIActivityViewController to call out the share option box:

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
objectsToShare
NSArray
UIImage

You can even remove some share options with:

controller.excludedActivityTypes = @[UIActivityTypeMessage, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];

before presenting the view controller to the user.

Also, you can modify the sharing content by implementing UIActivityItemSource protocol.

Is there a separate class for AirDrop? Also is it possible to add a bluetooth share in the UIActivityViewController?

ios - Trigger iPhone/iPads default photo share screen - Stack Overflow

ios iphone ipad share
Rectangle 27 63

Finally I got the answer. you can not directly post an image on instagram. You have to rediredt your image with UIDocumentInteractionController.

@property (nonatomic, retain) UIDocumentInteractionController *dic;    

CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];

NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect    inView: self.view animated: YES ];


- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
     UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
     interactionController.delegate = interactionDelegate;
     return interactionController;
}

NOTE : once you redirect to instagram app you can not back to your app. you have to open your app again

@SurenderRathore you have to scale your image into into 612*612 and save into .ig format .ig shows that you want to open your image into instagram and you have to test in your iPhone or iPod upto version 4.3 . iPad is not supported

@HiRen: Yes, you are right but in my app I am taking screenshot of a view and and then sharing that screenshot via instagram app and its perfectly working well. But I also want to pass some static text with that screenshot. If you have any idea please help me. There is a demo code on github for DMACtivityInstagram and you can see from there what I m trying to say. Thanks in advance.

@Bhavesh: It works in ios 6.

Using this line gave me a crash in iOS 6: NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]]; Using this works in both: NSURL *igImageHookFile = [NSURL fileURLWithPath:jpgPath]; Might be worth editing the answer accordingly, unless I'm missing something?

objective c - How to share an image on Instagram in iOS? - Stack Overf...

ios objective-c swift share instagram
Rectangle 27 1

What you need is to add an app extension with a Share extension type to your app. You can read more on app extensions here to get started.

ios - make an app appear in share panel to accept selected text from o...

ios iphone swift uiactivityviewcontroller
Rectangle 27 2

Just to give you a more comprehensive solution (for which Facebook is in fact an option), you can use a UIActivityViewController and exclude the irrelevant items in order to share to social media, for example to share to Facebook and Twitter you can exclude everything else like so:

let activityViewController = UIActivityViewController(activityItems:
  ["Whatever you want to share!"], applicationActivities: nil)
let excludeActivities = [
    UIActivityTypeMessage,
    UIActivityTypeMail,
    UIActivityTypePrint,
    UIActivityTypeCopyToPasteboard,
    UIActivityTypeAssignToContact,
    UIActivityTypeSaveToCameraRoll,
    UIActivityTypeAddToReadingList,
    UIActivityTypePostToFlickr,
    UIActivityTypePostToTencentWeibo,
    UIActivityTypeAirDrop]
activityViewController.excludedActivityTypes = excludeActivities;

presentViewController(activityViewController, animated: true,
  completion: nil)

Cool, that definitely filtered. For some reason the FB one still doesn't show up. Might just be a setting in the FB app

Yeah, it is. The only thing I'm passing along is the NSString and the documentation states that Facebook should react to NSStrings.

Figured it out. I wasn't signed into FB through the settings (weird, because I was through the app).

Is it possible to give my own preferred order of the apps? Say I want FB and Twitter to be the first ones in the Share Sheet, then followed by all the rest?

ios - How to share a String with sharing apps like Facebook, Twitter, ...

ios swift ios8 share ios-app-extension
Rectangle 27 9

You should be able to do this using:

UIImage *image1 = [UIImage imageNamed:@"image1"];
UIImage *image2 = [UIImage imageNamed:@"image2"];    
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[image1, image2] applicationActivities:nil];

How about images: [UIImage] = [image1, image2]. Then put the images to UIActivityViewController. I try this way, but it doesn't work.

You should make a separate SO question for that

ios - Share multiple images with UIActivityViewController - Stack Over...

ios objective-c uiactivityviewcontroller
Rectangle 27 9

You should be able to do this using:

UIImage *image1 = [UIImage imageNamed:@"image1"];
UIImage *image2 = [UIImage imageNamed:@"image2"];    
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[image1, image2] applicationActivities:nil];

How about images: [UIImage] = [image1, image2]. Then put the images to UIActivityViewController. I try this way, but it doesn't work.

You should make a separate SO question for that

ios - Share multiple images with UIActivityViewController - Stack Over...

ios objective-c uiactivityviewcontroller
Rectangle 27 24

Here is a full tested code to Upload image + caption text to Instagram..

//Instagram
@property (nonatomic, retain) UIDocumentInteractionController *documentController;

-(void)instaGramWallPost
{
            NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
            if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not
            {
                NSData *imageData = UIImagePNGRepresentation(imge); //convert image into .png format.
                NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
                NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
                NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"insta.igo"]]; //add our image to the path
                [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image)
                NSLog(@"image saved");

                CGRect rect = CGRectMake(0 ,0 , 0, 0);
                UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
                [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                UIGraphicsEndImageContext();
                NSString *fileNameToSave = [NSString stringWithFormat:@"Documents/insta.igo"];
                NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:fileNameToSave];
                NSLog(@"jpg path %@",jpgPath);
                NSString *newJpgPath = [NSString stringWithFormat:@"file://%@",jpgPath];
                NSLog(@"with File path %@",newJpgPath);
                NSURL *igImageHookFile = [[NSURL alloc]initFileURLWithPath:newJpgPath];
                NSLog(@"url Path %@",igImageHookFile);

                self.documentController.UTI = @"com.instagram.exclusivegram";
                self.documentController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
                self.documentController=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
                NSString *caption = @"#Your Text"; //settext as Default Caption
                self.documentController.annotation=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",caption],@"InstagramCaption", nil];
                [self.documentController presentOpenInMenuFromRect:rect inView: self.view animated:YES];
            }
            else
            {
                 NSLog (@"Instagram not found");
            }
}

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
    NSLog(@"file url %@",fileURL);
    UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
    interactionController.delegate = interactionDelegate;

    return interactionController;
}
-(void)instaGramWallPost
{
    NSURL *myURL = [NSURL URLWithString:@"Your image url"];
    NSData * imageData = [[NSData alloc] initWithContentsOfURL:myURL];
    UIImage *imgShare = [[UIImage alloc] initWithData:imageData];

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];

    if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not
    {
        UIImage *imageToUse = imgShare;
        NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
        NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];
        NSData *imageData=UIImagePNGRepresentation(imageToUse);
        [imageData writeToFile:saveImagePath atomically:YES];
        NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
        self.documentController=[[UIDocumentInteractionController alloc]init];
        self.documentController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
        self.documentController.delegate = self;
        self.documentController.annotation = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Testing"], @"InstagramCaption", nil];
        self.documentController.UTI = @"com.instagram.exclusivegram";
        UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
        [self.documentController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:vc.view animated:YES];
    }
    else {
        DisplayAlertWithTitle(@"Instagram not found", @"")
    }
}
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram</string>
    </array>

no... we have to come back manually... but if i found any solution i will update code...

I choose the Instagram button but nothing happens after that? Is there some additional code beyond this answer to do that?

objective c - How to share an image on Instagram in iOS? - Stack Overf...

ios objective-c swift share instagram
Rectangle 27 50

After some (a lot of) digging throughout the web, I found the answer. The access Group that you use when constructing your KeychainItemWrapper class must ALSO be specified in each of your application's Entitlements.plist file in the "keychain-access-groups" section.

It seems almost obvious now that I see "keychain-access-groups". However, I had no idea to even look there. Hope this helps others.

Be careful, in new XCode (4.5.2), there is a setting for keychain groups in app summary tab in settings. You can set the group name there, but smart XCode prepends $(AppIdentifierPrefix) but does not show it in the summary. You can see it in actual plist file and edit there. In short, if you are setting keychain group from summary page, do NOT write bundle seed ID, XCode adds it automatically. And hides it in the summary page, because it is, well, apple software.

I have a follow up question: Do your apps have the same bundle/developer seed ID? Or you just used the Entitlements.plist to share the data between keychain groups?

Is it possible to share keychain-access-groups with another company ? Let's say I create an app with and access group, but I want an app from another company to be able to share informations as well ?

If anyone still has a problem with error -25243 and trying to share same keychain between several apps, what worked for me is to set the keychain seed id hardcoded in the entitlements plist file instead of $(AppIdentifierPrefix) being automatically appended by XCode [url=postimg.org/image/52m2p4aor/][img=http://s9.postimg.org/

iphone - How to share keychain data between iOS applications - Stack O...

iphone ipad ios4 shared keychain
Rectangle 27 14

popoverPresentationController was new to iOS 8 and will crash on iOS 7. It'll also be nil on iPhone because it's only in a UIPopover on iPad. Here's Christian's answer in Swift, with those facts taken into account:

let controller = UIActivityViewController(activityItems: [text, url, myImage], applicationActivities: nil)

presentViewController(controller, animated: true, completion: nil)

if controller.respondsToSelector("popoverPresentationController") {
    // iOS 8+
    let presentationController = controller.popoverPresentationController
    presentationController?.sourceView = view
}

This answer is important if you're trying to use Swift on iOS 7 and 8. There's not a great way to check the version but this one works.

So I'm using the respondsToSelector("popoverPresentationController"), however when I Validate, iTunes rejects it saying it's a non-public selector. I'm guessing because it doesn't exist on iOS 7 (i.e. "non-public"), and our app is supposed to work on both 7 and 8. What's the solution here? Check iOS version?

if #available(iOS 8.0, *) { ... }

ios8 - Sharing via UIActivityViewController to Twitter/Facebook etc. c...

ios8 uiactivityviewcontroller
Rectangle 27 14

popoverPresentationController was new to iOS 8 and will crash on iOS 7. It'll also be nil on iPhone because it's only in a UIPopover on iPad. Here's Christian's answer in Swift, with those facts taken into account:

let controller = UIActivityViewController(activityItems: [text, url, myImage], applicationActivities: nil)

presentViewController(controller, animated: true, completion: nil)

if controller.respondsToSelector("popoverPresentationController") {
    // iOS 8+
    let presentationController = controller.popoverPresentationController
    presentationController?.sourceView = view
}

This answer is important if you're trying to use Swift on iOS 7 and 8. There's not a great way to check the version but this one works.

So I'm using the respondsToSelector("popoverPresentationController"), however when I Validate, iTunes rejects it saying it's a non-public selector. I'm guessing because it doesn't exist on iOS 7 (i.e. "non-public"), and our app is supposed to work on both 7 and 8. What's the solution here? Check iOS version?

if #available(iOS 8.0, *) { ... }

ios8 - Sharing via UIActivityViewController to Twitter/Facebook etc. c...

ios8 uiactivityviewcontroller