crystal_test
crystal_test

Reputation: 701

iOS hybrid app - Google Maps API error: RefererNotAllowedMapError

enter image description hereiOS hybrid app - Google Maps API error: RefererNotAllowedMapError

We are developing an iOS hybrid app.

  1. We have index.html and using cordova phone gap we have packaged and bundled as an app.

  2. We have also created a new key for google maps api.

After adding the new maps api it gives the error Google Maps API error: RefererNotAllowedMapError.

Since our app is a hybrid app we don't have a hosted url for Index.html

SO we have generated the Api Key for google Maps Javascript api using iOS bundle identifier.

Please help.

Upvotes: 0

Views: 2225

Answers (3)

Dylan w
Dylan w

Reputation: 2896

Our Ionic app was using the places API, we resolved the RefererNotAllowedMapError error by:

  1. Activating Maps javascript API and places API
  2. Set application restrictions to None (referer)
  3. Activated billing (step may not be required)
  4. Regenerated API key and replace old key with new key value in the code base

Everything was fixed, probably after regenerating the API key.

If you wish to add a referrer for Ionic, you will need to add the URL shown in the error thrown by the maps api (replace file:// with __file_url__)

Regenerate places API key

Upvotes: 1

Nheom Phearum
Nheom Phearum

Reputation: 35

It worked well after following these steps:

  1. Edit API Key.
  2. Under Application restrictions choose: HTTP referrers (web sites).
  3. Under Accept requests from these HTTP referrers insert domain with character: *
  4. Click Save.

Upvotes: 2

Nicolas Adrian
Nicolas Adrian

Reputation: 568

Make sure to use a browser key instead of an iOS key (the Maps Javascript API authorizes applications based on their referring domain).

Also note that file:// referers require a special config:

file:// referers need a special representation to be added to the Key restriction. The "file:/" part should be replaced with "file_url" before being added to the Key restriction. For example, "file://path/to/" should be formatted as "file_url/path/to/*". After enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations

https://developers.google.com/maps/documentation/javascript/get-api-key#key-restrictions

Upvotes: 1

Related Questions