Class: PEM::DeveloperCenter

Inherits:
FastlaneCore::DeveloperCenter
  • Object
show all
Defined in:
lib/pem/developer_center.rb

Constant Summary collapse

APP_IDS_URL =
"https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action"

Instance Method Summary collapse

Instance Method Details

#fetch_cer_fileObject

This method will enable push for the given app and download the cer file in any case, no matter if it existed before or not

Returns:

  • the path to the push file


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pem/developer_center.rb', line 11

def fetch_cer_file
  @app_identifier = PEM.config[:app_identifier]
  begin
    open_app_page

    click_on "Edit"
    wait_for_elements(".item-details") # just to finish loading

    push_value = first(:css, '#pushEnabled').value
    if push_value == "on"
      Helper.log.info "Push for app '#{@app_identifier}' is enabled"
    else
      Helper.log.warn "Push for app '#{@app_identifier}' is disabled. This has to change."
      first(:css, '#pushEnabled').click
      sleep 3 # this takes some time
    end

    if has_actual_cert and not PEM.config[:force]
      Helper.log.info "You already have a push certificate, which is active for more than 30 more days. No need to create a new one".green
      Helper.log.info "If you still want to create a new one, use the --force option when running PEM.".green
      false
    else
      Helper.log.warn "Creating push certificate for app '#{@app_identifier}'."
      create_push_for_app
    end
  rescue => ex
    error_occured(ex)
  end
end

#has_actual_certObject


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pem/developer_center.rb', line 41

def has_actual_cert
  apps = all(:xpath, "//div[@class = 'certificate']")
  cert_type = PEM.config[:development] ?  'Development' : 'Production'
  cert_section = apps.select { |c| c.text.include? cert_type }

  unless cert_section.empty?
    data_s = cert_section.last.all('dd').last.text
    data = Date.parse(data_s)
    data - Time.now.to_date > 30  # valid for more than 30 days (Apple email)
  end
end