reown-com / a2

An Asynchronous Apple Push Notification (apns2) Client for Rust
MIT License
150 stars 52 forks source link

More type safety #5

Closed dbrgn closed 6 years ago

dbrgn commented 6 years ago

This is part of the NotificationOptions:

    /// If you are using a provider token instead of a certificate, you must
    /// specify a value for this request header. The topic you provide should be
    /// provisioned for the your team named in your developer account.
    pub apns_topic: Option<String>,

It would be great if it were impossible to pass this to a client initialized with a provider token. Maybe two types of notification options could be provided?

For ergonomics, both could implement a common trait that converts the checked option types to an unchecked version.

pimeys commented 6 years ago

This is kind of problematic, because you can change the topic per message using the same connection. So basically one token connection can deliver messages to one app, but that app can use different topics.

If you have some ideas how to do this better, I'm up for pull requests here!

dbrgn commented 6 years ago

Hm, I see... Not sure what the best approach might be here... :slightly_smiling_face:

Maybe when sending a push that combination could be at least checked before actually sending the request? Or does the API return clear error messages?

pimeys commented 6 years ago

You'll get an error for wrong topic from Apple.

dbrgn commented 6 years ago

Ok, I guess that is fine then.