noticed: iOS delivery method does not allow cert_path to be a string
I encountered an issue when a custom cert_path method returns a StringIO.new("certificate_content_here") object instead of a file.
If I have this code below and an empty config/certs/ios/apns.p8 file, the push notification gets delivered without an issue.
class SomeNotification
deliver_by :ios, {
format: :ios_format,
cert_path: ios_cert_path,
}
def ios_cert_path
StringIO.new(Rails.application.credentials.dig(:ios, :apn_certificate).to_s)
end
end
However if the p8 file gets deleted, this exception shows up
ArgumentError: Could not find APN cert at '.../config/certs/ios/apns.p8'
from .../noticed-1.5.2/lib/noticed/delivery_methods/ios.rb:12:in `deliver'
I believe the code should be able to handle a cert_path with a string content and not restrict it from always getting the certificate from a file.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
@excid3 submitted a PR for it 😄 Let me know what you think!
Ah yeah! This easy enough?
Then we can include an example in the docs for
FileorStringIOobjects. I don’t think we really need a validation for those, do you?I was hoping it would be that as well but there is a guard clause in
Noticed::DeliveryMethods::Iosthat checks whether thecert_pathfile existsFWIW, I usually commit my p8 files to the repo and put the team ID and key in Rails credentials. That way even if someone got the p8 they couldn’t use it unless they also got access to your credentials.