Class: Grocer::SafariNotification
Overview
Public: A specialized form of a Grocer::Notification for sending Safari push notifications
Examples
Grocer::SafariNotification.new(
device_token: '...',
title: '...',
body: '...',
action: '...',
url_args: ['...']
)
{
"aps": {
"alert": {
"title": "...",
"body": "...",
"action": "..."
},
"url-args": ["..."]
}
}
Constant Summary
Constants inherited
from Notification
Notification::CONTENT_AVAILABLE_INDICATOR, Notification::MAX_PAYLOAD_SIZE
Instance Attribute Summary
Attributes inherited from Notification
#alert, #badge, #category, #content_available, #custom, #device_token, #expiry, #identifier, #sound
Instance Method Summary
collapse
#content_available?, #to_bytes, #valid?
Constructor Details
Returns a new instance of SafariNotification.
30
31
32
33
|
# File 'lib/grocer/safari_notification.rb', line 30
def initialize(payload = {})
self.alert = {}
super(payload)
end
|
Instance Method Details
#action ⇒ Object
53
54
55
|
# File 'lib/grocer/safari_notification.rb', line 53
def action
alert[:action]
end
|
#action=(action) ⇒ Object
57
58
59
60
|
# File 'lib/grocer/safari_notification.rb', line 57
def action=(action)
alert[:action] = action
@encoded_payload = nil
end
|
#body ⇒ Object
44
45
46
|
# File 'lib/grocer/safari_notification.rb', line 44
def body
alert[:body]
end
|
#body=(body) ⇒ Object
48
49
50
51
|
# File 'lib/grocer/safari_notification.rb', line 48
def body=(body)
alert[:body] = body
@encoded_payload = nil
end
|
#title ⇒ Object
35
36
37
|
# File 'lib/grocer/safari_notification.rb', line 35
def title
alert[:title]
end
|
#title=(title) ⇒ Object
39
40
41
42
|
# File 'lib/grocer/safari_notification.rb', line 39
def title=(title)
alert[:title] = title
@encoded_payload = nil
end
|
#url_args ⇒ Object
62
63
64
|
# File 'lib/grocer/safari_notification.rb', line 62
def url_args
Array(@url_args)
end
|
#url_args=(args) ⇒ Object
66
67
68
69
|
# File 'lib/grocer/safari_notification.rb', line 66
def url_args=(args)
@url_args = args.dup
@encoded_payload = nil
end
|