From c31b6c5b931fc3f4f0504cce06267d3f5131c009 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 8 Apr 2024 01:58:44 +0200 Subject: [PATCH] Add support for Notification#content_available (#8) --- lib/push/notification.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/push/notification.rb b/lib/push/notification.rb index fa5c989..16967c0 100644 --- a/lib/push/notification.rb +++ b/lib/push/notification.rb @@ -279,6 +279,23 @@ def category_id(value) raise ArgumentError, 'categoryId must be string-like or nil' end + ## + # Set or overwrite content available. + # + # Must be a boolean or nil, or an ArgumentError is raised. + # + # On iOS, use this to trigger a background fetch action. + # Under normal circumstances, the "content-available" flag should launch + # your app if it isn't running and wasn't killed by the user. However, + # this is ultimately decided by the OS, so it might not always happen. + # + def content_available(value) + raise ArgumentError, 'content_available must be boolean or nil' unless [true, false, nil].include?(value) + + _params[:contentAvailable] = value + self + end + ## # Set or overwrite the mutability flag. #