Skip to content

SharePoster is to help users post content(image, video, url, etc..) in Share Extension

License

Notifications You must be signed in to change notification settings

sihon321/SharePoster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharePoster

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 4.2

Installation

SharePoster is available through CocoaPods. To install it, simply add the following line to your Podfile:

 pod 'SharePoster'

Usage

  • An example implementation of didSelectPost
- (void)didSelectPost {
    // Perform the post operation.
    // When the operation is complete (probably asynchronously), the Share extension should notify the success or failure, as well as the items that were actually shared.
 
    NSExtensionItem *inputItem = self.extensionContext.inputItems.firstObject;
 
    NSExtensionItem *outputItem = [inputItem copy];
    outputItem.attributedContentText = [[NSAttributedString alloc] initWithString:self.contentText attributes:nil];
    // Complete this implementation by setting the appropriate value on the output item.
 
    NSArray *outputItems = @[outputItem];
 
    [self.extensionContext completeRequestReturningItems:outputItems expirationHandler:nil completion:nil];
// Or call [super didSelectPost] to use the superclass's default completion behavior.
}
  • SharePoster
override func viewDidLoad() {
  sharePoster = SharePoster(extensionContext?.inputItems)
  
  sharePoster.loadData {
      defer {
        DispatchQueue.main.async {
          self.collectionView.reloadData()
        }
      }

      self.images = sharePoster.contentsItem.getContents()
  }
}

ContentsItem.swift

public struct ContentsItem {
  
  var contents: [URL]
  
  var documents: [String]
  
  var urls: [(url: URL, title: String)]
  
  ...
  
}

Author

sihon321, sihon321@gmail.com

License

SharePoster is available under the MIT license. See the LICENSE file for more info.

About

SharePoster is to help users post content(image, video, url, etc..) in Share Extension

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published