- Notifications
You must be signed in to change notification settings - Fork124
Remote configuration for iOS
License
mattt/GroundControl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Remote configuration for iOS
Note: This project is no longer being maintained.
Many developers don't realize that they are allowed to remotely control the behavior of their app (provided that the application isn't downloading any new code).
GroundControl gives you a dead-simple way to remotely configure your app, allowing you to add things likefeature flags, impromptuA/B tests, or a simple"message of the day".
It's built on top ofAFNetworking, and provides a single category onNSUserDefaults
(just add#import "NSUserDefaults+GroundControl.h"
to the top of any file you want to use it in).
NSURL *URL = [NSURLURLWithString:@"http://example.com/defaults.plist"];[[NSUserDefaultsstandardUserDefaults]registerDefaultsWithURL:URL];
...or if you need callbacks for success/failure, and prefer not to listen for aNSUserDefaultsDidChangeNotification
:
NSURL *URL = [NSURLURLWithString:@"http://example.com/defaults.plist"];[[NSUserDefaultsstandardUserDefaults]registerDefaultsWithURL:URLsuccess:^(NSDictionary *) {// ...}failure:^(NSError *) {// ...}];
...or if you need to use an HTTP method other than GET, or need to set any special headers, specify anNSURLRequest
:
NSURL *URL = [NSURLURLWithString:@"http://example.com/defaults.plist"];NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:URL];[[NSUserDefaultsstandardUserDefaults]registerDefaultsWithURLRequest:requestsuccess:^(NSURLRequest *,NSHTTPURLResponse *,NSDictionary *) {// ...}failure:^(NSURLRequest *,NSHTTPURLResponse *,NSError *) {// ...}];
GroundControl asynchronously downloads and reads a remote plist file. This could be a static file or generated dynamically, like in the following examples (see also the complete Sinatra application found inexample/server
):
require'sinatra'require'plist'get'/defaults.plist'docontent_type'application/x-plist'{'Greeting'=>"Hello, World",'Price'=>4.20,'FeatureXIsLaunched'=>true}.to_plistend
fromdjango.httpimportHttpResponseimportplistlibdefproperty_list(request):plist= {'Greeting':"Hello, World",'Price':4.20,'FeatureXIsLaunched':True,'Status':1 }returnHttpResponse(plistlib.writePlistToString(plist))
varplist=require('plist'),express=require('express')varhost="127.0.0.1"varport=8080varapp=express()app.get("/",function(request,response){response.send(plist.build({'Greeting':"Hello, World",'Price':4.20,'FeatureXIsLaunched':true,'Status':1}).toString())})app.listen(port,host)
GroundControl is available under the MIT license. See the LICENSE file for more info.