Reputation: 701
iOS hybrid app - Google Maps API error: RefererNotAllowedMapError
We are developing an iOS hybrid app.
We have index.html and using cordova phone gap we have packaged and bundled as an app.
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
Reputation: 2896
Our Ionic app was using the places API, we resolved the RefererNotAllowedMapError error by:
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__
)
Upvotes: 1
Reputation: 35
It worked well after following these steps:
Upvotes: 2
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