gpt4 book ai didi

ios - 有没有办法从 Gmail native 应用程序中快速获取用户的用户名(电子邮件地址)?

转载 作者:行者123 更新时间:2023-11-30 13:05:21 24 4
gpt4 key购买 nike

为了额外说明,这是我迄今为止尝试过的:

  1. 我正在检查是否通过以下代码安装了 Gmail native 应用:

    let urlPath:String = "googlegmail://q"
    let url: NSURL = NSURL(string: urlPath)!

    let isInstalled = UIApplication.sharedApplication().canOpenURL(url)
    if isInstalled {
    print("Installed")
    }else{
    print("Not installed")
    }
  2. 接下来,我只是尝试获取用户用于访问电子邮件的用户名(这就是我陷入困境的地方)。

我不想使用私有(private) api,而只想使用公开可用的 api。

最佳答案

首先您需要确认Google Plus的Delegate,即GIDSignInDelegate、GIDSignInUIDelegate之后使委托(delegate) self 并添加范围

GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/contacts")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.login")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.stream.read")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.me")`

//MARK:- get Info of user from google api
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!){
if (error == nil){
getGoogleContacts()
}
}`

private func getGoogleContacts(){


guard let currentUserToken = GIDSignIn.sharedInstance().currentUser.authentication.accessToken else{
userAuthenticate()
return
} GNServerAPIProcessor.requestForGetGoogleContactsFromGmail(currentUserToken) { (responseValue, error) in
if error == nil{
if responseValue != nil{`// here is user result with email
}
}
}``

关于ios - 有没有办法从 Gmail native 应用程序中快速获取用户的用户名(电子邮件地址)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39454297/

24 4 0
文章推荐: javascript - 使用 Google Maps API v3 添加多个标记
文章推荐: javascript - jquery 移动转义页面
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com