2

I have a javascript file in my iOS app that I need to update frequently and I'd like to be able to do that from a server rather than submitting new app updates every time I update the javascript file. I have filezilla, an account with dreamhost and a website I could host the file on, if that helps. I also have a Parse account.

I have this code in my app but I would like to load this from somewhere other than inside the app so that I can easily update it:

NSString *jsString = [NSString stringWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"GPS" withExtension:@"js"] encoding:NSUTF8StringEncoding error:nil]; [_viewWeb stringByEvaluatingJavaScriptFromString:jsString];

Any help would be greatly appreciated!

Thank you,

  • Creagen
Creagen
  • 478
  • 5
  • 17
  • 1
    Are you asking how to send an HTTP request? – SLaks Aug 20 '15 at 17:01
  • Maybe. I'm not sure. I'm using this code to load the javascript file within my app NSString *jsString = [NSString stringWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"GPS" withExtension:@"js"] encoding:NSUTF8StringEncoding error:nil]; [_viewWeb stringByEvaluatingJavaScriptFromString:jsString]; BUT i'd like to load that file from outside the app, so that I can easily update it. – Creagen Aug 20 '15 at 17:04

1 Answers1

1

You should probably look into getting an Amazon Web Services EC2 Instance (a web server). This way you'll be able to just update the Javascript code on your server without having to modify the iOS app itself.

Once you have the web server set up you should take a look at how to send an HTTP GET request to the server to pull in the Javascript code.

I would check out this question: How to connect to EC2 instance within an iOS App

And this one: How to send a Get request in iOS?

And this link about EC2: https://aws.amazon.com/ec2/

There's plenty of documentation online to do this both on Stackoverflow and on the AWS site so you should be fine. It might seem kind of confusing at first but I've done it myself and once you get the hang of it, it's really not that bad.

Community
  • 1
  • 1
Wyetro
  • 8,439
  • 9
  • 46
  • 64