module DeployGateIOS
Public Instance Methods
api_key=(key)
click to toggle source
# File lib/ios.rb, line 6 def api_key=(key) @api_key = key end
sdk=(sdk)
click to toggle source
# File lib/ios.rb, line 24 def sdk=(sdk) @sdk = sdk @config.vendor_project( sdk, :static, :products => ['DeployGateSDK'], :headers_dir => 'Headers' ) @config.frameworks << 'SystemConfiguration' create_launcher apply_patch end
url_scheme=(scheme)
click to toggle source
# File lib/ios.rb, line 15 def url_scheme=(scheme) @config.info_plist['CFBundleURLTypes'] = [ { 'CFBundleURLName' => @config.identifier, 'CFBundleURLSchemes' => [scheme] } ] end
user_id=(id)
click to toggle source
# File lib/ios.rb, line 2 def user_id=(id) @user_id = id end
user_infomation=(bool)
click to toggle source
# File lib/ios.rb, line 10 def user_infomation=(bool) @user_infomation = bool end
Also aliased as: user_information=
Private Instance Methods
apply_patch()
click to toggle source
# File lib/ios.rb, line 67 def apply_patch Dir.glob(File.join(@sdk, "Headers") + "/*.h") do |file| file = File.expand_path(file) data = File.read(file) new_data = [] data.each_line do |line| # replace "typedef enum" declaration to avoid http://hipbyte.myjetbrains.com/youtrack/issue/RM-479 if line.strip == "typedef enum DeployGateSDKOption : NSUInteger {" new_data << "typedef enum DeployGateSDKOption {\n" else new_data << line end end new_data = new_data.join if data != new_data File.open(file, "w") do |io| io.write new_data end end end end
create_launcher()
click to toggle source
# File lib/ios.rb, line 39 def create_launcher return unless @user_id && @api_key launcher_code = <<EOF # This file is automatically generated. Do not edit. if Object.const_defined?('DeployGateSDK') and !UIDevice.currentDevice.model.include?('Simulator') NSNotificationCenter.defaultCenter.addObserverForName(UIApplicationDidFinishLaunchingNotification, object:nil, queue:nil, usingBlock:lambda do |notification| DeployGateSDK.sharedInstance.launchApplicationWithAuthor('#{@user_id}', key:'#{@api_key}', userInfomationEnabled:#{@user_infomation}) end) class #{@config.delegate_class} unless #{@config.delegate_class}.method_defined?("application:openURL:sourceApplication:annotation:") def application(application, openURL:url, sourceApplication:sourceApplication, annotation:annotation) return DeployGateSDK.sharedInstance.handleOpenUrl(url, sourceApplication:sourceApplication, annotation:annotation) end end end end EOF launcher_file = './app/deploygate_launcher.rb' if !File.exist?(launcher_file) or File.read(launcher_file) != launcher_code File.open(launcher_file, 'w') { |io| io.write(launcher_code) } end @config.files.unshift(launcher_file) end