Module: MotionWechat::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/motion-wechat/config.rb

Instance Method Summary collapse

Instance Method Details

#info_plist_keyObject


5
6
7
# File 'lib/motion-wechat/config.rb', line 5

def info_plist_key
  "WechatConfig"
end

#setup(app, key, secret, opts = {}) ⇒ Object

Setup wechat information to rubymotion app, i.e. key, secret…

Example: (in Rakefile)

Motion::Project::App.setup do |app|
  ...
  MotionWechat::Config.setup(app, 'app_key', 'app_secret')
end

Arguments:

RubyMotion app: (Motion::Project::App)
Wechat key:     (String)
Wechat secret:  (String)
other options:  (Hash)

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/motion-wechat/config.rb', line 23

def setup(app, key, secret, opts={})
  options = {
    key: key,
    secret: secret
  }.merge(opts)

  app.info_plist[info_plist_key] = options.select { |k| k == :key || k == :secret }

  bundle_url_types = [
      { 'CFBundleURLName'    => "weixin",
        'CFBundleURLSchemes' => [app.info_plist[info_plist_key][:key]] }
    ]

  app.info_plist['CFBundleURLTypes'] ||= []
  app.info_plist['CFBundleURLTypes'] << bundle_url_types
  
end