IOS - ObjC Google Maps Api Key

一个人想着一个人 提交于 2020-01-04 02:27:08

问题


i just did everything right as mentioned here but Xcode still gives that error:

  Google Maps SDK for iOS cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x8416b20 {data=<CFData 0x9187710 [0x27424d8]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2013-09-01 15:04:04.902 MyApp[1357:12e03] Your key may be invalid for your bundle ID: MyBundleID

So i 've googled it and got these: first result, second result, and it started to be boring from now on. Is there a way to make this mail thing faster, or am i doing wrong something still ?


回答1:


Ohh, i've got the answer. Maybe someone needs it. Just clean {} these signs from your API KEY, i mean it shouldn't be like below

[GMSServices provideAPIKey:@"{123123123}"];

it should be like :

[GMSServices provideAPIKey:@"123123123"];



回答2:


Two things I would suggest double checking:

  1. Be aware that the Bundle Identifier is case sensitive. If the capitalization is off in the application, or within the google development console, it will through this error.

    • Extra tip.. you can double check your application's bundle identifier by including a log similar to the following in your viewDidLoad method.
    NSLog(@"Current identifier: %@", [[NSBundle mainBundle] bundleIdentifier]);
  2. Make sure you've included the API key in your applications delegate as listed by Sercan Ozdemir above. Your App's delegate file should contain a method similar to the one below.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        [GMSServices provideAPIKey:@"INSERT_GOOGLE_API_KEY_HERE"];
        return YES;
    }
    



回答3:


I too faced the same problem even though I did everything correctly. I made a mistake at choosing the framework. I had taken GoogleMapsM4B.framework instead of GoogleMaps.framework. I overcame this error after choosing suitable framework from this link.

This might be helpful to someone.



来源:https://stackoverflow.com/questions/18558303/ios-objc-google-maps-api-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!