![](https://dontpaniclabs.com/wp-content/uploads/2024/07/sending-apns-notifications-featured.webp)
Sending APNS Push Notifications Using C#
Over the years, we have built many mobile applications across numerous industries. One of the most common features of these mobile applications is sending push notifications.
Most applications we have built have used third-party services to send these notifications.
But how hard is it to send APNS notifications? It’s really not that hard.
But why would we do this and not use another service? First off, I like to know what other services are doing. It is helpful to know what the magic is beneath the surface. Second, we in software are sometimes too focused on layering services to solve our problems, but sometimes just writing a few lines of code is easier.
First, we will include a NuGet package, dotAPNS
. This package lets us send push notifications to an iOS device straight from C#.
Setting up dotAPNS
is pretty straightforward.
First, we must get a device token. Getting a device token can be done in a variety of ways. I will write a separate blog post on how to do this from an Ionic mobile application.
Second, we must initialize our options.
Then we just send a push notification. This is very straightforward.
The response from the call above is very informative if you are receiving errors.
Feel free to give this a try. If you like it, reach out to me on X (@chadmichel).