UIActivityViewController share only text

前端 未结 5 792
旧时难觅i
旧时难觅i 2021-01-02 17:13

I want to share just simple text using UIActivityViewController I am using swift, with xcode 6.3 The code is very simple, work great for photos, but not just text, I don\'t

相关标签:
5条回答
  • 2021-01-02 17:47

    After doing some research, I was able to find the following solution to the problem:

    func shareTapped() {
        let vc = UIActivityViewController(activityItems: [detailImageView.image!, "Check out these photos! http://www.photolib.noaa.gov/nssl"], applicationActivities: [])
        presentViewController(vc, animated: true, completion: nil)
    

    So in ActivityItems, you can pass an image then comma and then pass a string variable or open " and enter your text directly " in the enable above this worked with Facebook and Twitter in the UIActivityViewController.

    0 讨论(0)
  • 2021-01-02 17:49

    I have been facing the same problem but have not been able to fix it. This is what I found out so far:

    • Bug can be fixed when removing Facebook.app from device (but it's not a solution)
    • Bug seems to persist on devices with Facebook.app >v28.0 & iOS8.3
    • Facebook.app v28.0 & iOS8.3 still works
    • Facebook.app v29.0 & iOS8.2 still works
    • Sharing URL's seems to be affected too by this bug

    It's hard to tell if Facebook actually has something to do with this bug, as they have a policy of entering bogus release notes for updates.

    Since the sharing feature is not a main feature in my app, I will wait until the release of iOS8.4 and/or Facebook.app v30.0

    0 讨论(0)
  • 2021-01-02 17:53

    I just tested on my example, using this code:

    @IBAction func shareMoment_Action(sender: AnyObject) {
    let firstActivityItem = "This is a simple text"
    var activityVC = UIActivityViewController(activityItems: [firstActivityItem], applicationActivities: nil)
    
        activityVC.excludedActivityTypes = [
            UIActivityTypePostToWeibo,
            UIActivityTypePrint,
            UIActivityTypeCopyToPasteboard,
            UIActivityTypeAssignToContact,
            UIActivityTypeSaveToCameraRoll,
            UIActivityTypeAddToReadingList,
            UIActivityTypePostToFlickr,
            UIActivityTypePostToVimeo,
            UIActivityTypePostToTencentWeibo,
            UIActivityTypeAirDrop
        ]
    
        activityVC.completionWithItemsHandler = {(activityType: String!, completed: Bool, arrayOptions: [AnyObject]!, error: NSError!) in
            println(activityType)
        }
    
        self.presentViewController(activityVC, animated: true, completion: nil)
    }
    

    And share is working fine for every option selected! Here is TW Here is the FB Here is from App

    It is working well on my side. Please check your code again!

    0 讨论(0)
  • 2021-01-02 17:57

    It seems that it is not a bug but facebook policy update:

    "After discussing this with our team regarding stripping the pre-filling message area of text, this is actually BY DESIGN with the new share extension. Pre-filling texts violates Platform Policy 2.3 ..... So in all enforcing policy 2.3 is a feature and not a bug. " https://developers.facebook.com/bugs/949486035103197/

    0 讨论(0)
  • 2021-01-02 18:11

    I read and the problem isn't iOS 8.3, is FacebookApp v29 and they haven't fix it on today update. If you uninstall your FacebookApp it works.

    I can´t post images, but if you try this code with Facebook app installed and without it you will see the difference

    func didPressShare(sender: AnyObject) {
        if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
            var facebookSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
            facebookSheet.setInitialText("This is without facebook on device")
            self.presentViewController(facebookSheet, animated: true, completion: nil)
        } else {
            var alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.Alert)
            alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
            self.presentViewController(alert, animated: true, completion: nil)
        }
    

    }

    As they said: "Sorry for the delay everyone but we have this fix scheduled for v31. The reason for the delay is the cycle for getting updates approved for the App Store takes time. We appreciate your patience."

    https://developers.facebook.com/bugs/949486035103197/

    They say it will be fixed on next update.

    0 讨论(0)
提交回复
热议问题