Class: Notifun::Notifier::CloudFiveNotifier
- Inherits:
-
ParentNotifier
- Object
- ParentNotifier
- Notifun::Notifier::CloudFiveNotifier
- Defined in:
- lib/notifun/notifiers/cloud_five_notifier.rb
Instance Attribute Summary
Attributes inherited from ParentNotifier
Instance Method Summary collapse
Methods inherited from ParentNotifier
Constructor Details
This class inherits a constructor from Notifun::Notifier::ParentNotifier
Instance Method Details
#notify!(text, title, uuid, options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/notifun/notifiers/cloud_five_notifier.rb', line 2 def notify!(text, title, uuid, ) if !defined?(CloudFivePush) @success = false @error_message = "CloudFivePush is not defined." return end api_key = [:api_key].presence api_key ||= Notifun.configuration.push_config[:api_key] return false unless api_key.present? notification = CloudFivePush::Notification.new(api_key) if title.present? notification.alert = title notification. = text else notification.alert = text notification. = "" end notification.user_identifiers = [uuid] notification.data = [:push_data] notification.content_available = [:content_available] notification.badge = [:badge].presence response = notification.notify! if response['success'] @success = true else @error_message = response["error"].presence || "Failed to send push notification" @success = false end end |