• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

mattt/GroundControl: Remote configuration for iOS

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

mattt/GroundControl

开源软件地址:

https://github.com/mattt/GroundControl

开源编程语言:

Objective-C 93.4%

开源软件介绍:

GroundControl

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 like feature flags, impromptu A/B tests, or a simple "message of the day".

It's built on top of AFNetworking, and provides a single category on NSUserDefaults (just add #import "NSUserDefaults+GroundControl.h" to the top of any file you want to use it in).

Client Code

NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
[[NSUserDefaults standardUserDefaults] registerDefaultsWithURL:URL];

...or if you need callbacks for success/failure, and prefer not to listen for a NSUserDefaultsDidChangeNotification:

NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
[[NSUserDefaults standardUserDefaults] registerDefaultsWithURL:URL
  success:^(NSDictionary *) {
    // ...
} failure:^(NSError *) {
    // ...
}];

...or if you need to use an HTTP method other than GET, or need to set any special headers, specify an NSURLRequest:

NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[[NSUserDefaults standardUserDefaults] registerDefaultsWithURLRequest:request
  success:^(NSURLRequest *, NSHTTPURLResponse *, NSDictionary *) {
    // ...
} failure:^(NSURLRequest *, NSHTTPURLResponse *, NSError *) {
    // ...
}];

Server Code

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 in example/server):

Ruby

require 'sinatra'
require 'plist'

get '/defaults.plist' do
  content_type 'application/x-plist'

  {
    'Greeting' => "Hello, World",
    'Price' => 4.20,
    'FeatureXIsLaunched' => true
  }.to_plist
end

Python

from django.http import HttpResponse
import plistlib

def property_list(request):
    plist = {
         'Greeting': "Hello, World",
         'Price': 4.20,
         'FeatureXIsLaunched': True,
         'Status': 1
    }

    return HttpResponse(plistlib.writePlistToString(plist))

Node.js

var plist = require('plist'),
    express = require('express')

var host = "127.0.0.1"
var port = 8080

var app = 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)

License

GroundControl is available under the MIT license. See the LICENSE file for more info.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap