Ios 获取请求中提供的API密钥无效
我正在尝试创建我的第一个应用程序,不幸的是,每个人都记得他们用一种新语言编写的第一段代码,不用说,这是一个半小时的麻烦。现在,我正在使用下载的测试文件来了解如何使用swift实现Firebase。目前,除了让应用程序在创建用户到数据库时记录电子邮件并传递外,我不太关心其他事情 我已经对GoogleService-Info.plist进行了两次和三次检查,以确保有正确的API密钥。在检查包ID和所有其他信息是否正确后,我已经多次下载了Google文件。该应用程序加载并运行,允许我输入电子邮件和密码,一旦我点击按钮注册,就会抛出无效API错误。 这就是我的播客文件的样子Ios 获取请求中提供的API密钥无效,ios,swift,firebase,firebase-authentication,Ios,Swift,Firebase,Firebase Authentication,我正在尝试创建我的第一个应用程序,不幸的是,每个人都记得他们用一种新语言编写的第一段代码,不用说,这是一个半小时的麻烦。现在,我正在使用下载的测试文件来了解如何使用swift实现Firebase。目前,除了让应用程序在创建用户到数据库时记录电子邮件并传递外,我不太关心其他事情 我已经对GoogleService-Info.plist进行了两次和三次检查,以确保有正确的API密钥。在检查包ID和所有其他信息是否正确后,我已经多次下载了Google文件。该应用程序加载并运行,允许我输入电子邮件和密码
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FirebaseTutorial' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FirebaseTutorial
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
end
这是注册的功能代码
@IBAction func createAccountAction(_ sender: AnyObject) {
if emailTextField.text == "" {
let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
present(alertController, animated: true, completion: nil)
} else {
FIRAuth.auth()?.createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in
if error == nil {
print("You have successfully signed up")
//Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
} else {
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
}}
这是AppDelegate.swift中的代码
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
让我知道,如果有什么我可以提供,以获得一些帮助,这方面。我感到非常绝望,每一次谷歌搜索和搜索都让我创建了一个帐户并问了这个问题。每个人都必须从正确的地方开始?您需要在“API错误”周围包含错误日志,以便我们能够在正确的方向上帮助您。编辑:您是否在API服务器上配置了SSL?如果不是,iOS可能只是简单地阻止您的HTTP连接,因为它不安全。然后你需要将它添加到PLIST中以避免它被阻塞,好吧,让我们看看这是否是你正在寻找的。。。我觉得自己是超级新手,但这就是我在调试器窗口中看到的(我想就是这样)
2017-01-28 23:03:37.842285 FirebaseTutorial[89583:2934913][MobileAssetError:29]无法从中复制资产信息https://mesu.apple.com/assets/ 对于资产类型com.apple.mobileaset.TextInput.SpellChecker
我相信API服务器上的SSL已配置。如果我假设正确,这意味着API密钥本身是安全的,只能由iOS应用程序使用我的应用程序包ID访问。我觉得很失落@这正是问题所在:,请检查解决方案。但是,我不确定这是否是导致连接错误的原因。您需要打印出从与API的实际连接中获得的确切错误消息。单击“提交”按钮将文本字段内容发布到服务器后,打印服务器响应。我知道我的XCode和POD是最新的,它们都是在24小时前安装的,但我只是为了确保更新。你能告诉我怎样才能打印出准确的错误消息,以及在哪里可以找到服务器响应吗。。。如果它甚至到达服务器。在实时数据库图表上,Firebase确实记录了在过去几个小时内处理此问题时遇到的一些KBs,但我不知道这是否意味着它来自模拟器或其他不相关的工具。我对Firebase或Swift都不熟悉,但是,请尝试在您调用的(用户,错误)方法中打印错误。您正在发射一个带有错误消息的警报,消息上说什么?