GoogleMap apiKey


I successfully have the Google Map working with my app. I entered my GoogleMap apiKey into the apiKey section of the control.
Is there a way to add this in code instead such as like GoogleMap1.apiKey = “sdfsfd” ?

In the future if the apiKey changes, i may not be able to change it from within my app iteself.


Don’t add it to your code!!!

Hackers will unpack your app, take your code and use/sell it.

Instead, when you register your user or save your push registration token, pass the key back to the app, save it and move forward.

BUG ALERT: Also, make sure the device is online before trying to load the Google maps code. If you load the maps in your header and the device is offline the maps won’t get loaded so when you try to use a map, the user gets a bug.

Thanks for your advice.

When you say to ‘save’ the api key, you mean to a database?
For my apps, i deploy the same app using PhoneGap and as a webapp depending on the project. Should our main URL and PHP used to call our server be retrieved in a similar manner and stored in a database instead of fixing it in code?


Save meaning to a local point. In a browser app, you have access to localStorage which is pretty stable. This is also the case on Android but on iOS there are no guarantees that localStorage will persist beyond the current running of the app. You have the option of using sqlLite across all three platforms or saving as a file.

I have a local file that has all my app settings stored as json and a set of setters/getters with the underlying json code for reading/writing the file. On startup, I read the json from file, convert it to an object and use as necessary. When a setting gets changed, I use a setter to update the object in memory and then calls a method to convert the object to json and update the file.


Thanks for your reply.
I currently store all my settings in sqlLite. What file type do you save as?
Do you store your URL or PHP file names in there also and get them as required?

I just store as a text file with json encoded objects. Simple to read, write etc. not at all visible on iOS.

SqlLite is probably the better way, I think it’s on our roadmap but it’s pretty far down the street.