-
Notifications
You must be signed in to change notification settings - Fork 1
SocialHelper
The social helper class allows quick access to some social aspects, such as presenting an email/message. This class has a private singleton it used for dleegate methods, so that every presenting view controller does not have to impliment them seperately.
Declaration
Swift
private enum AlertViewTags: Int
---
<br>
### toRecipients
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private var toRecipients: [String] = []
Declaration
Swift
private var ccRecipients: [String] = []
---
<br>
### bccRecipients
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private var bccRecipients: [String] = []
Declaration
Swift
private var subject: String = ""
---
<br>
### messageBody
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private var messageBody: String = ""
Declaration
Swift
private var isBodyHTML: Bool = false
---
<br>
### emailAttachments
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private var emailAttachments: [(data: NSData, mimeType: String, fileName: String)] = []
Declaration
Swift
private var messgaeAttachments: [(attachmentURL: NSURL, alternateFilename: String)] = []
---
<br>
### viewController
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private var viewController: UIViewController?
Declaration
Swift
private var animated: Bool = true
---
## Singleton
<br>
### shared
**Declaration**
> <sub>**Swift**</sub>
> ```swift
private class var shared: SocialHelper
Declaration
Swift
struct Singleton{ static let instance : SocialHelper = SocialHelper() }
**Constants**
- `instance`
---
<br>
### init()
**Declaration**
> <sub>**Swift**</sub>
> ```swift
override private init()
Declaration
Swift
private func clear()
---
## Methods
<br>
### presentComposeViewController(_:initialText:urls:images:inViewController:animated:)
Presents a compose view controller with the details passed in.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public class func presentComposeViewController(serviceType: String, initialText: String? = nil, urls: [NSURL]? = nil, images: [UIImage]? = nil, inViewController viewController: UIViewController, animated: Bool = true)
Parameters
`serviceType` | The type of service type to present. For a list of possible values, see Service Type Constants. |
`initialText` | The initial text to show in the `SLComposeViewController`. |
`urls` | The URLs to attach to the `SLComposeViewController`. |
`images` | The images to attach to the `SLComposeViewController`. |
`viewController` | The view controller to present the `SLComposeViewController` in. |
`animated` | If the presentation should be animated or not. |
Returns a NSURL to call with openURL(_:)
in UIApplication
parsed from a number string.
Declaration
Swift
public class func phonePromptFormattedURL(#number: String) -> NSURL?
**Parameters**
<table>
<tr><td> `number` </td><td> The number to parse in to create the URL. </td></tr>
<table>
**Return Value**
The URL of the parsed phone number, prefixed with `telprompt://`.
---
<br>
### emailPrompt(toRecipients:ccRecipients:bccRecipients:subject:messageBody:isBodyHTML:attachments:viewController:animated:)
Creates a prompt for an email with the following parameters to pass into the `MFMailComposeViewController`.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public class func emailPrompt(#toRecipients: [String], ccRecipients: [String] = [], bccRecipients: [String] = [], subject: String = "", messageBody: String = "", isBodyHTML: Bool = false, attachments: [(data: NSData, mimeType: String, fileName: String)] = [], viewController: UIViewController, animated: Bool = true)
Parameters
`toRecipients` | The email addresses of the recipients of the email. |
`ccRecipients` | The email addresses of the CC recipients of the email. |
`bccRecipients` | The email addresses of the BCC recipients of the email. |
`subject` | The subject of the email. |
`messageBody` | The main body of the email. |
`isBodyHTML` | Tells the `MFMailComposeViewController` if the message body is HTML. |
`attachments` | The attachments to add to the email, passed in as a tuple of data, mime type and the file name. |
`viewController` | The view controller to present the `MFMailComposeViewController` in. |
`animated` | If the presentation should be animated or not. |
presentMailComposeViewController(toRecipients:ccRecipients:bccRecipients:subject:messageBody:isBodyHTML:attachments:viewController:animated:)
Declaration
Swift
private class func presentMailComposeViewController(#toRecipients: [String], ccRecipients: [String], bccRecipients: [String], subject: String, messageBody: String, isBodyHTML: Bool, attachments: [(data: NSData, mimeType: String, fileName: String)], viewController: UIViewController, animated: Bool)
---
<br>
### messagePrompt(recipients:subject:body:attachments:viewController:animated:)
Creates a prompt for a message with the following parameters to pass into the `MFMessageComposeViewController`.
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public class func messagePrompt(#recipients: [String], subject: String = "", body: String = "", attachments: [(attachmentURL: NSURL, alternateFilename: String)] = [], viewController: UIViewController, animated: Bool = true)
Parameters
`recipients` | The recipients of the message. |
`subject` | The subject of the message. |
`body` | The main body of the message. |
`attachments` | The attachments to add to the message, passed in as a tuple of attachment URL and alternate filename. |
`viewController` | The view controller to present the `MFMailComposeViewController` in. |
`animated` | If the presentation should be animated or not. |
Declaration
Swift
private class func presentMessageComposeViewController(#recipients: [String], subject: String, body: String, attachments: [(attachmentURL: NSURL, alternateFilename: String)], viewController: UIViewController, animated: Bool)
---
## Methods
<br>
### mailComposeController(_:didFinishWithResult:error:)
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!)
Declaration
Swift
public func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)
---
## Methods
<br>
### alertView(_:clickedButtonAtIndex:)
**Declaration**
> <sub>**Swift**</sub>
> ```swift
public func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int)