谷歌加登录时直接到某个地方

时间:2015-08-11 07:29:52

标签: ios xcode swift google-app-engine login

我遇到了麻烦,我做了这样的界面enter image description here

当我使用谷歌登录时,它运行良好,并接受权限,但是,错误来了,它重定向到我的旧应用程序。它进入第二个视图(nutrisi,但旧的,而不是新的) enter image description here

正如你所看到的那样(新的有按钮,旧的没有按钮......) 。 到现在为止,我仍然感到困惑,登录后我应该编辑哪些代码和重定向代码

这是我的登录代码

    //Google Plus(Google+,G+)

import UIKit

import AddressBook
import MediaPlayer
import AssetsLibrary
import CoreLocation
import CoreMotion


class SignInViewController: UIViewController,GPPSignInDelegate {
    //fungsi login ke google plus dan tombol tombol beserta permintaan / persyaratan yang harus disetujui
    @IBOutlet weak var btnGPlus: GPPSignInButton!
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var loadingActivityIndicator: UIActivityIndicatorView!
    let clientId = "555994724868-qpbo9ibls9f2i1ftnokcs8cs40b8ejot.apps.googleusercontent.com";
    let clientSecret = "AnYSDvyeLMWWaqFIWWAsO5ij";
    var signIn:GPPSignIn?


    override func viewDidLoad() {
        super.viewDidLoad()
        btnGPlus.hidden = false
        signIn = GPPSignIn.sharedInstance()
        btnGPlus.style = kGPPSignInButtonStyleWide
        btnGPlus.colorScheme = kGPPSignInButtonColorSchemeDark
        signIn?.shouldFetchGooglePlusUser = true
        signIn?.shouldFetchGoogleUserID = true
        signIn?.shouldFetchGoogleUserEmail = true
        signIn?.clientID = clientId
        signIn?.scopes = ["profile"]
        signIn?.delegate = self;
        // Do any additional setup after loading the view, typically from a nib.
        signIn?.trySilentAuthentication()
        //signIn.authenticate()
        loadingActivityIndicator.startAnimating()
        btnGPlus.hidden = true


        if signIn?.trySilentAuthentication() == false {
            loadingActivityIndicator.stopAnimating()
            loadingActivityIndicator.hidden = true
            btnGPlus.hidden = false
        }



    }

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

    func finishedWithAuth(auth: GTMOAuth2Authentication!, error: NSError!) {

        label.text = auth.userEmail
       print("login success \(auth.userEmail)")
        println("\(signIn?.googlePlusUser.displayName)")
       var cc = signIn?.googlePlusUser.name.familyName
       println("\(cc)")
        println(error)
    }

     func logout(){

        GPPSignIn.sharedInstance().signOut()

    }


    func didFinishSelector(){

    }

    func googlePlusContactsCallback(ticket: GTLServiceTicket!, returnObject: AnyObject?, error: NSError!) {
       /*
        if(error != nil){
            print("\(error)")
            return
        }
        let res  = object as GTLSwiftsampleapiPostRes
        print("\(res.message) \(res.identifier) \(res.registeredAt) \(res.email)")*/
    }


    func didDisconnectWithError(error: NSError!) {
        println("connect fail")
    }



}

0 个答案:

没有答案