Skip to content

IOS Notification Key #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/rpush/client/active_model/fcm/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module Notification
default_vibrate_timings default_light_settings vibrate_timings
visibility notification_count light_settings].freeze

IOS_NOTIFICATION_KEYS = %w[title subtitle body launch-image title-loc-key title-loc-args
subtitle-loc-key subtitle-loc-args loc-key loc-args].freeze

def self.included(base)
base.instance_eval do
validates :device_token, presence: true
Expand Down Expand Up @@ -78,6 +81,7 @@ def apns_config
aps['content-available'] = 1 if content_available
aps['sound'] = 'default' if sound == 'default'
aps['badge'] = badge if badge
aps['alert'] = ios_notification if notification

json['payload']['aps'] = aps

Expand All @@ -103,6 +107,12 @@ def android_notification
json
end

def ios_notification
return {} unless notification

notification.slice(*IOS_NOTIFICATION_KEYS)
end

def priority_str
case
when priority <= 5 then 'normal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class NotificationKeysInAllowedListValidator < ::ActiveModel::Validator
def validate(record)
return unless record.notification

allowed_keys = Notification::ROOT_NOTIFICATION_KEYS + Notification::ANDROID_NOTIFICATION_KEYS
allowed_keys = Notification::ROOT_NOTIFICATION_KEYS + Notification::ANDROID_NOTIFICATION_KEYS + Notification::IOS_NOTIFICATION_KEYS
invalid_keys = record.notification.keys - allowed_keys

return if invalid_keys.empty?
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy