IOS - ObjC Google Maps Api Key

2019-07-01 11:47发布

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 ?

3条回答
Explosion°爆炸
2楼-- · 2019-07-01 12:28

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楼-- · 2019-07-01 12:31

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.

查看更多
ら.Afraid
4楼-- · 2019-07-01 12:49

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"];
查看更多
登录 后发表回答