TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Victor Amelin.
Depends on: | |
FBSDKCoreKit | >= 0 |
FBSDKLoginKit | >= 0 |
VK-ios-sdk | >= 0 |
SocialToolKit purpose is to get access token from Facebook or VK. You can use it to get token from specific social network, or from several (now supports only Facebook and VKontakte).
How to install:
Requirements:
iOS 9.0+
Swift 3.0
Installing with CocoaPods:
use_frameworks!
pod 'SocialToolKit'
How to use:
For Facebook:
Update this three methods in your AppDelegate:
1.
import SocialToolKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
SocialToolKit.sharedInstance.appFBDidFinishLaunchingWithOptions(application: application, launchOptions: launchOptions)
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
SocialToolKit.sharedInstance.appFBDidBecomeActive()
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
SocialToolKit.sharedInstance.appFBOpenURL(app: app, url: url, options: options)
return true
}
Insert the following XML snippet into the body of your file just before the final element.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{your-app-id}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
import SocialToolKit
SocialToolKit.sharedInstance.requestFacebookToken(permissions: ["public_profile", "user_friends"], loginBehavior: FBSDKLoginBehavior.systemAccount, { (token, error) in
if error == nil {
print("TOKEN: \(token)")
} else {
print("ERROR: \(error?.localizedDescription)")
}
})
For VK:
import SocialToolKit
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
SocialToolKit.sharedInstance.appVKOpenURL(sourceApplication: sourceApplication, url: url)
return true
}
URL Schemes: vk1234567 Role: Editor
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>vk.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
false/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vk</string>
<string>vk-share</string>
<string>vkauthorize</string>
</array>
If you are using FB iOS SDK and VK iOS SDK it looks like this:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>vk</string>
<string>vk-share</string>
<string>vkauthorize</string>
</array>
SocialToolKit.sharedInstance.requestVKToken(permissions: ["friends", "photos"], appId: "your app id") { (token, error) in
if error == nil {
print("TOKEN: \(token)")
} else {
print("ERROR: \(error?.localizedDescription)")
}
}
LICENCE:
Copyright © 2017 Stfalcon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.