-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShareManager.swift
59 lines (50 loc) · 1.75 KB
/
ShareManager.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// ShareManager.swift
// Kapıştır
//
// Created by Evren Yortuçboylu on 02/08/16.
// Copyright © 2016 Evren Yortuçboylu. All rights reserved.
//
import Foundation
import UIKit
import FacebookCore
import FacebookShare
import Social
class ShareManager: NSObject {
private var kapistirImage: UIImage!
init(kapistirImage: UIImage) {
self.kapistirImage = kapistirImage
}
func facebookNative() {
do{
let photo = Photo(image: self.kapistirImage, userGenerated: true)
var content = PhotoShareContent(photos: [photo])
let shareDialog = ShareDialog(content: content)
content.hashtag = Hashtag("kapıştır")
shareDialog.mode = .Native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
// Handle share results
print("bitti")
}
try shareDialog.show()
}
catch(let error){
print("hata: \(error)")
}
}
func facebook() {
let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc.setInitialText("#kapıştır")
vc.addImage(self.kapistirImage)
// vc.addURL(NSURL(string: "http://www.google.com"))
App.UI.getTopMostViewController().presentViewController(vc, animated: true, completion: nil)
}
func twitter() {
let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
vc.setInitialText("#kapıştır")
vc.addImage(self.kapistirImage)
// vc.addURL(NSURL(string: "http://www.google.com"))
App.UI.getTopMostViewController().presentViewController(vc, animated: true, completion: nil)
}
}