Add Firebase configuration
- Update local script to load Firebase key - Configure Firebase projectId in push.yml
This commit is contained in:
committed by
Rosa Gutierrez
parent
55336873b2
commit
7d04bb514f
@@ -7,4 +7,4 @@ shared:
|
||||
connect_to_development_server: <%= Rails.env.local? %>
|
||||
google:
|
||||
encryption_key: <%= (ENV["FCM_ENCRYPTION_KEY"] || Rails.application.credentials.dig(:action_push_native, :fcm, :key))&.dump %>
|
||||
project_id: your-firebase-project # Your Firebase project ID (not secret)
|
||||
project_id: fizzy-a148c
|
||||
|
||||
+27
-15
@@ -1,36 +1,48 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Fetches APNs development environment variables from 1Password.
|
||||
# Fetches APNs and FCM development environment variables from 1Password.
|
||||
#
|
||||
# Usage: eval "$(bundle exec apns-dev)"
|
||||
|
||||
OP_ACCOUNT = "23QPQDKZC5BKBIIG7UGT5GR5RM"
|
||||
OP_VAULT = "Mobile"
|
||||
OP_ITEM = "37signals Push Notifications key"
|
||||
OP_APNS_ITEM = "37signals Push Notifications key"
|
||||
OP_FCM_ITEM = "Fizzy Firebase Push Notification Private Key"
|
||||
|
||||
def op_read(field)
|
||||
`op read "op://#{OP_VAULT}/#{OP_ITEM}/#{field}" --account #{OP_ACCOUNT} 2>/dev/null`.strip
|
||||
def op_read(item, field)
|
||||
`op read "op://#{OP_VAULT}/#{item}/#{field}" --account #{OP_ACCOUNT} 2>/dev/null`.strip
|
||||
end
|
||||
|
||||
key_id = op_read("key ID")
|
||||
team_id = op_read("team ID")
|
||||
encryption_key = op_read("AuthKey_3CR5J2W8Q6.p8")
|
||||
# APNs credentials
|
||||
apns_key_id = op_read(OP_APNS_ITEM, "key ID")
|
||||
apns_team_id = op_read(OP_APNS_ITEM, "team ID")
|
||||
apns_encryption_key = op_read(OP_APNS_ITEM, "AuthKey_3CR5J2W8Q6.p8")
|
||||
|
||||
if key_id.empty? || encryption_key.empty?
|
||||
# FCM credentials (JSON file attachment)
|
||||
fcm_encryption_key = op_read(OP_FCM_ITEM, "fizzy-a148c-firebase-adminsdk-fbsvc-bdc640ce13.json")
|
||||
|
||||
if apns_key_id.empty? || apns_encryption_key.empty?
|
||||
warn "Error: Could not fetch APNs credentials from 1Password"
|
||||
warn "Make sure you're signed in: op signin --account #{OP_ACCOUNT}"
|
||||
exit 1
|
||||
end
|
||||
|
||||
puts %Q(export APNS_KEY_ID="#{key_id}")
|
||||
puts %Q(export APNS_TEAM_ID="#{team_id}")
|
||||
puts %Q(export APNS_ENCRYPTION_KEY="#{encryption_key.gsub("\n", "\\n")}")
|
||||
if fcm_encryption_key.empty?
|
||||
warn "Warning: Could not fetch FCM credentials from 1Password"
|
||||
warn "Android push notifications will not work"
|
||||
end
|
||||
|
||||
puts %Q(export APNS_KEY_ID="#{apns_key_id}")
|
||||
puts %Q(export APNS_TEAM_ID="#{apns_team_id}")
|
||||
puts %Q(export APNS_ENCRYPTION_KEY="#{apns_encryption_key.gsub("\n", "\\n")}")
|
||||
puts %Q(export APNS_TOPIC="do.fizzy.app.ios")
|
||||
puts %Q(export FCM_ENCRYPTION_KEY='#{fcm_encryption_key.gsub("'", "'\\\\''")}')
|
||||
puts %Q(export ENABLE_NATIVE_PUSH="true")
|
||||
|
||||
warn ""
|
||||
warn "APNs credentials loaded for development"
|
||||
warn " Key ID: #{key_id}"
|
||||
warn " Team ID: #{team_id}"
|
||||
warn " Topic: do.fizzy.app.ios"
|
||||
warn "Push notification credentials loaded for development"
|
||||
warn " APNs Key ID: #{apns_key_id}"
|
||||
warn " APNs Team ID: #{apns_team_id}"
|
||||
warn " APNs Topic: do.fizzy.app.ios"
|
||||
warn " FCM: #{fcm_encryption_key.empty? ? "not configured" : "configured"}"
|
||||
warn " Native push: enabled"
|
||||
|
||||
Reference in New Issue
Block a user