swift - In Xcode, UIActivityViewController does not display any options as in sharing on social media such as sharing on Facebook, Twitter, etc -


i tried including uiactivityviewcontroller in xcode project (swift), ran app in simulator, uiactivityviewcontroller didn't include options of sharing content (i thought once include can options such "share on facebook" , "share on twitter"

here's code:

import uikit class viewcontroller: uiviewcontroller {       @ibaction func sharetextbutton(_ sender: uibutton) {           let text = "this text want share."           let texttoshare = [ text ]         let activityviewcontroller = uiactivityviewcontroller(activityitems: texttoshare, applicationactivities: nil)         activityviewcontroller.popoverpresentationcontroller?.sourceview = self.view // ipads won't crash            self.present(activityviewcontroller, animated: true, completion: nil)      }       @ibaction func shareimagebutton(_ sender: uibutton) {           let image = uiimage(named: "portrait")           let imagetoshare = [ image! ]         let activityviewcontroller = uiactivityviewcontroller(activityitems: imagetoshare, applicationactivities: nil)         activityviewcontroller.popoverpresentationcontroller?.sourceview = self.view // ipads won't crash                   self.present(activityviewcontroller, animated: true, completion: nil)     }  } 

here's appeared in debug console:

2017-04-05 18:32:34.902268-0700 aa[26541:4024236] [mc] system group container systemgroup.com.apple.configurationprofiles path /users/cuiboy/library/developer/coresimulator/devices/55f2de69-127a-4f0e-871f-4e431586d8af/data/containers/shared/systemgroup/systemgroup.com.apple.configurationprofiles objc[26541]: class plbuildversion implemented in both /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator.sdk/system/library/privateframeworks/assetslibraryservices.framework/assetslibraryservices (0x11a182cc0) , /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator.sdk/system/library/privateframeworks/photolibraryservices.framework/photolibraryservices (0x119f996f0). 1 of 2 used. 1 undefined. 2017-04-05 18:32:35.141398-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.posttotwitter => com.apple.share.twitter.post 2017-04-05 18:32:35.141532-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.posttofacebook => com.apple.share.facebook.post 2017-04-05 18:32:35.141629-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.posttoweibo => com.apple.share.sinaweibo.post 2017-04-05 18:32:35.141728-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.tencentweibo => com.apple.share.tencentweibo.post 2017-04-05 18:32:35.141801-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.posttoflickr => com.apple.share.flickr.post 2017-04-05 18:32:35.141904-0700 aa[26541:4024236] [core] slcomposeviewcontroller extensionidentifierforactivitytype: com.apple.uikit.activity.posttovimeo => com.apple.share.vimeo.post 2017-04-05 18:32:35.325040-0700 aa[26541:4024236] [mc] reading private effective user settings.

does know wrong? can make facebook , twitter , other social media options appear in activity view controller?

you have coded correctly.

there excludedactivitytypes property can code want exclude, nothing excluded whatever available on device appear (meaning if facebook or twitter isn't on device, won't). since using simulator, these options not appear.

on side note, debug console implies seeing lot of "info" may wish remove. if so, choose build scheme (upper left in xcode), choose "edit scheme", , add following environment variable:

name: os_activity_mode

value: disable


Comments