recurring_notification
This block will be executed when a user has granted or removed permissions to receive recurring notifications from Messenger.
Platform | Supported |
---|---|
Messenger | |
WhatsApp | |
Telegram |
In order to make this event occurs, a notification request must be send to the user by calling the method
recurring_notification_request()
.
class MainContext < Conversation
def actions
recurring_notification :granted do |data|
@reply.text "Thanks for subscribing to #{data[:frecuency]} notifications" end
recurring_notification :removed do |data|
# Here you can handle the removed permission event
end
payload :get_started do
@reply.text "Welcome!"
@reply.notification.recurring_notification_request(
{
title: "Whould you like to receive weekly notifications from us?",
image_url: "https://previews.123rf.com/images/aquir/aquir1909/aquir190907932/129839413-bot%C3%B3n-de-suscripci%C3%B3n-suscr%C3%ADbete-letrero-rojo-redondeado-suscribir.jpg?fj=1",
payload: :subscribe,
frequency: :weekly,
reoptin: true
}
)
end
end
end
{
token: "XXXXXXXXXXXXXXXXXXXXXX",
frecuency: "WEEKLY",
expires_at: "2023-03-21 12:27:09 UTC",
token_status: "NOT_REFRESHED",
timezone: "UTC",
status: "active"
}
{
token: "XXXXXXXXXXXXXXXXXXXXXX",
frecuency: "WEEKLY",
expires_at: "2023-03-21 12:27:09 UTC",
token_status: "NOT_REFRESHED",
timezone: null,
status: "stopped"
}
To send a notification using the recurring notification token, just call
send_using_token()
method instead of send()
.user = u = User.where(platform: "messenger").first
user.notification.text "Hello World!"
user.notification.send_using_token()
Last modified 10mo ago