2017-08-21 8 views
1

client.example.comのようなすべてのクライアントにサブドメインを使用し、そのドメインをマスクしました。私はソーシャルログインGoogle、FacebookとLinkedInを追加しました。マスクされたドメインのソーシャルログイン

FacebookとLinkedInログインするためにURLを押すと、Googleログインの問題がその空白のページを表示しているようです。

マスクされたドメインにソーシャルログインを使用することは可能ですか?

他の2人はうまく動作しているため、Googleではエラーが発生していないため、解決策を見つけられなかったためです。

プロジェクトはLaravel-5.1であると私は任意のヘルプは素晴らしい

だろう名士

を使用pod 'Google/SignIn'
ステップ2
用ポッドファイルをインストールし、事前に

答えて

0

ステップ1
をありがとう追加するコードは次のとおりです。AppDelegate

AppDelegate.swift 輸入のUIKit インポートグーグル 輸入GoogleSignIn 輸入FacebookCore

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
var configureError: NSError? 
     GGLContext.sharedInstance().configureWithError(&configureError) 
     assert(configureError == nil, "Error configuring Google services: \(String(describing: configureError))") 

    return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) 
} 

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 

print("Google+ url scheme") 
      return GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation) 

} 

@available(iOS 9.0, *) 
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool { 

print("Google+ url scheme") 
      let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String 
      let annotation = options[UIApplicationOpenURLOptionsKey.annotation] 
      return GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation) 
} 

ViewController.swift

import UIKit 
    import GoogleSignIn 
    import FacebookCore 
    import FacebookLogin 

    class ViewController: UIViewController, GIDSignInDelegate, GIDSignInUIDelegate { 

     @IBOutlet weak var profileImage: UIImageView! 
     @IBOutlet weak var emailText: UITextField! 
     @IBOutlet weak var passwordText: UITextField! 
     @IBOutlet weak var rememberMeSegment: UISwitch! 
     @IBOutlet weak var appSignInButton: UIButton! 
     @IBOutlet weak var googleSignInButton: UIButton! 
     @IBOutlet weak var facebookSignInButton: UIButton! 
     @IBOutlet weak var appSignUpButton: UIButton! 

     override func viewDidLoad() { 
      super.viewDidLoad() 

     self.profileImage.layer.masksToBounds = false 
     self.profileImage.layer.cornerRadius = self.profileImage.frame.height/2 
     self.profileImage.clipsToBounds = true 
    } 

    override func viewWillAppear(_ animated: Bool) { 
     super.viewWillAppear(animated) 

     self.navigationController?.navigationBar.isHidden = true 
    } 
     @IBAction func googleSignIn(sender: UIButton) { 
     GIDSignIn.sharedInstance().scopes = ["https://www.googleapis.com/auth/plus.login","https://www.googleapis.com/auth/plus.me"] 
     GIDSignIn.sharedInstance().shouldFetchBasicProfile = true 
     GIDSignIn.sharedInstance().uiDelegate = self 
     GIDSignIn.sharedInstance().delegate = self 
     GIDSignIn.sharedInstance().signIn() 
    } 

    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { 

     if (error == nil) { 

      print("Name : \(user.profile.name!)") 
      print("Email : \(user.profile.email!)") 

      if let email = user.profile.email { 
       self.emailText.text = email 
      } 

      if(user.profile.hasImage){ 
       print("Profile Image : \(user.profile.imageURL(withDimension: 100))") 

       self.profileImage.downloadedFrom(link: user.profile.imageURL(withDimension: 100).absoluteString) 

      } else { 
       print("Profile Image : Profile image not available") 
      } 

      GIDSignIn.sharedInstance().signOut() 
      GIDSignIn.sharedInstance().disconnect() 

     } else { 
      let alertController = UIAlertController(title: "Error", message: "\(error.localizedDescription)") 
      self.present(alertController, animated: true, completion: nil) 
     } 

    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 

- extension String { 
      func hexStringToUIColor() -> UIColor { 
       var cString:String = self.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() 


     if (cString.hasPrefix("#")) { 
      cString.remove(at: cString.startIndex) 
     } 

     if ((cString.characters.count) != 6) { 
      return UIColor.gray 
     } 

     var rgbValue:UInt32 = 0 
     Scanner(string: cString).scanHexInt32(&rgbValue) 

     return UIColor(
      red: CGFloat((rgbValue & 0xFF0000) >> 16)/255.0, 
      green: CGFloat((rgbValue & 0x00FF00) >> 8)/255.0, 
      blue: CGFloat(rgbValue & 0x0000FF)/255.0, 
      alpha: CGFloat(1.0) 
     ) 
    } 
} 

extension UIAlertController { 
    convenience init(title: String, message: String) { 
     self.init(title: title, message: message, preferredStyle: .alert) 
     let action = UIAlertAction(title: NSLocalizedString("OK", comment: "OK action"), style: .default, handler: nil) 
     addAction(action) 
    } 
}