2017-08-21 4 views
1

J'utilise un sous-domaine pour tous les clients comme client.exemple.com puis j'ai masqué leur domaine par-dessus. J'ai ajouté les connexions sociales Google, Facebook et LinkedIn.Connexions sociales avec domaine masqué

Facebook et LinkedIn semble fonctionner, mais le problème avec Google Login est de montrer une page blanche vierge lorsque je clique sur l'URL de connexion.

est-il possible d'utiliser les connexions sociales pour le domaine masqué? Parce que les deux autres fonctionnent bien et google ne jette aucune erreur donc ne pouvait pas trouver la solution.

projet est Laravel-5.1 et j'utiliser Socialite

Toute aide serait grande

Nous vous remercions à l'avance

Répondre

0

étape 1
Installer Pod fichier pour pod 'Google/SignIn'
étape 2
Pour le code ci-dessous, ajouter AppDelegate

AppDelegate.swift importation UIKit importation Google importation GoogleSignIn importation 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) 
    } 
}