Skip to content

allow voip type - #88

Open
kelleyduran wants to merge 5 commits into
ostinelli:masterfrom
convo:allow-set-push-type
Open

kelleyduran wants to merge 5 commits into
ostinelli:masterfrom
convo:allow-set-push-type

Conversation

@kelleyduran

Copy link
Copy Markdown

proposed fix for invalidpushtype error #87

Comment thread lib/apnotic/request.rb Outdated
if notification.type
h.merge!('apns-push-type' => notification.type)
else
h.merge!('apns-push-type' => notification.background_notification? ? 'background' : 'alert' )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would defer to the owner here but here we have two ways of doing the if statement for the same function... I would suggest...

if notification.type
  ..
elsif notification.background_notification?
  ...
else
  ...
end

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was trying to maintain some backwards compatibility in cases where the type is not set, using the approach you're proposing allows us to be more specific and would allow us to just set voip type if we want to eliminate generic type

Comment thread lib/apnotic/notification.rb Outdated
class Notification < AbstractNotification
attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args, :mutable_content, :thread_id
attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args,
:mutable_content, :thread_id, :type

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the rest of the project, I think type might be a bit too generic.... what about voip as a boolean?

@kelleyduran kelleyduran Oct 18, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reading the apple documentation here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns I think only one apns-push-type is allowed. Due to that, I think we should ensure that we are not allowing more push type values to be set. This is why I decided to go with type, and it could be set to the following values

  • voip
  • mdm
  • fileprovider
  • complication
  • alert
  • background

Since we are only concerned with voip we could limit the scope to just that, if we think that works better?

@ostinelli
ostinelli force-pushed the master branch 2 times, most recently from 90a8855 to 49e105d Compare September 24, 2020 13:01
@benubois

benubois commented Sep 7, 2021

Copy link
Copy Markdown
Collaborator

Hi @kelleyduran,

Thanks for your work on this!

What I'd like to see is a proper wrapper around the apns-push-type key, with an eye toward maintaining backward compatibility with background_notification?.

The .voip method is an interesting idea, but I think just specifying the value of apns-push-type with an attr_accessor of push_type would be the most consistent with the current API. In addition to voip, there's also alert, background, location, complication, fileprovider, mdm, so to be consistent, apnotic would have to offer a corresponding method for all of these, and be updated every time a new one is added.

I know it's been a long time so if you're not interested or available to do this work I would understand and we can close this PR.

Ben

@dfabreguette

Copy link
Copy Markdown

Hi, I need to setup voip push notifications.
Is this going to be merged to master anytime ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants