Skip to content

Instantly share code, notes, and snippets.

View Jerry0420's full-sized avatar
🏠
Looking for a remote job.

Yen Lung Wang Jerry0420

🏠
Looking for a remote job.
View GitHub Profile
@Jerry0420
Jerry0420 / gist:18f5afd0bfa514d2fd441d196a8c3324
Created October 12, 2016 04:40
將以下程式碼加入AppDelegate內
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
var error : NSError?
GGLContext.sharedInstance().configureWithError(&error)
if error != nil{
print(error)
}
@Jerry0420
Jerry0420 / gist:23a15bd3a3e28ac68a4436d49f1b7a1d
Created October 12, 2016 04:41
將這個view(GIDSignInButton)拉進ViewController內
@IBOutlet weak var signInButton: GIDSignInButton!
import UIKit
import GoogleSignIn
class ViewController: UIViewController,GIDSignInUIDelegate,GIDSignInDelegate {......}
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if error != nil{
print(error)
return
}else{
print(user.userID)
print(user.profile.email)
print(user.profile.imageURL(withDimension: 400))
}
@IBAction func signOut(_ sender: UIButton) {
GIDSignIn.sharedInstance().signOut()
}
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>CFBundleURLTypes</key>
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
import UIKit
import FBSDKLoginKit
class ViewController: UIViewController,FBSDKLoginButtonDelegate {......}
override func viewDidLoad() {
super.viewDidLoad()
faceBookLogIn.readPermissions = ["public_profile", "email", "user_friends"]
faceBookLogIn.delegate = self
// 第一次登入後可取得使用者token,後續即可直接登入
if (FBSDKAccessToken.current()) != nil{
// fetchProfile()
}