在我的iOS应用中集成Google地图 1.生成的API密钥 2.为iOS应用定义关键限制和应用程序包ID 3.添加了pod 4.在我的AppDelegate中定义了api密钥为
func application(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - > Bool { //在应用程序启动后覆盖自定义点。 UIApplication.shared.statusBarStyle = .lightContent GMSServices.provideAPIKey(AIzaSyA8D1awYfmGSQuhmtY_TSqtafUXMtQjeuk)返回true }5.启动应用程序并查看空地图视图。 在日志中我看到:
引用:2017-06-16 19:15:27.842 {app name} [12134:333695] Google Maps SDK for iOS无法连接或验证APIKey:错误域= com.google.HTTPStatus代码= 400 (空) 的UserInfo = {数据= LT; 3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 30303030 543d2223 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>} 2017-06-16 19:15:27.842 {app name} [12134:333695]你的钥匙可能是对于您的软件包ID无效:{bundle id} 我忘了做什么? 我尝试了什么: 我检查了我的应用程序包ID,它是正确的(从Xcode复制粘贴)
解决方案我忘了在google开发者控制台中启用Google Maps iOS SDK。
Integrated Google maps in my iOS app 1. generated API key 2. defined key restriction for iOS app and app bundle ID 3. added pod 4. defined api key in my AppDelegate as
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. UIApplication.shared.statusBarStyle = .lightContent GMSServices.provideAPIKey("AIzaSyA8D1awYfmGSQuhmtY_TSqtafUXMtQjeuk") return true }5. launch app and see empty map view. In log I see this:
Quote:2017-06-16 19:15:27.842 {app name}[12134:333695] Google Maps SDK for iOS cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data=<3c48544d 4c3e0a3c 48454144 3e0a3c54 49544c45 3e426164 20526571 75657374 3c2f5449 544c453e 0a3c2f48 4541443e 0a3c424f 44592042 47434f4c 4f523d22 23464646 46464622 20544558 543d2223 30303030 3030223e 0a3c4831 3e426164 20526571 75657374 3c2f4831 3e0a3c48 323e4572 726f7220 3430303c 2f48323e 0a3c2f42 4f44593e 0a3c2f48 544d4c3e 0a>} 2017-06-16 19:15:27.842 {app name}[12134:333695] Your key may be invalid for your bundle ID: {bundle id}
What did I forget to do? What I have tried: I checked my app bundle id, it is correct (copy-pasted from Xcode)
解决方案 I forgot enable Google Maps iOS SDK in google developer console.更多推荐
Google Maps for iOS不显示地图
发布评论