Push Notification Practices?

Alex Kozler 6 Reputation points
2021-02-09T22:25:57.277+00:00

I have been wanting to leave OneSignal for my Xamarin.Forms app for a while now due to slow updates to their libraries, especially Xamarin.Android ones. I've been looking into alternatives including Azure Notification Hubs but there are some things unclear that I was hoping for clarity on:

  1. One of the things I liked about OneSignal was that the device registration happens at their end, not mine. If someone downloads my app to their phone, their registration IDs get sent to OneSignal and I only worry about sending push notifications from my WebAPI through a tag like a username. Can I do this with Azure Notification Hubs? From what I gather from the documentation it seems I have to have client cellphones ping my WebAPI, then I register them @ Azure, but I don't have to host registration IDs on my own end, correct?
  2. All of my users sign into my app with a username. They may be on multiple devices with the same username. They may also sign in and out of various accounts from the same device. Can I target users for push notifications reliably by username and not by having to ping specific registration IDs?
  3. How does de-registration work? If a user logs out of my app, or uninstalls it, will their registration be automatically removed from Azure Notification Hubs???

I really appreciate any advice or tips here... or even if there are other third party solutions that do this.

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
325 questions
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,363 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 21,691 Reputation points
    2021-02-11T05:59:33.573+00:00

    Thanks for asking question.

    You may want to know that Azure Notification Hubs eliminates all complexities associated with sending push notifications on your own from your app backend. Its multi-platform, scaled-out push notification infrastructure reduces push-related coding and simplifies your backend. With Notification Hubs, devices are merely responsible for registering their PNS handles with a hub, while the backend sends messages to users or interest groups, as shown in the following figure:

    66854-what-is-azure-notification-hubs-microsoft-docs.png

    It has rich set of delivery patterns which include Push notifications send to specific users: Tags and templates help you reach all cross-platform devices for a user.

    Further to elaborate on How Registration happens in Azure Notification hubs in order to receive push notifications:

    There are the two main patterns for registering devices:

    1. Registration management from the device directly to the notification hub: The device first retrieves the PNS handle from the PNS, then registers with the notification hub directly. After the registration is
      successful, the app backend can send a notification targeting that registration. So When managing device registration from client
      apps, the backend is only responsible for sending notifications. Client apps keep PNS handles up-to-date, and register tags.
    2. Registration management from a backend: The advantages of managing registrations from the backend include the ability to modify tags to registrations even when the
      corresponding app on the device is inactive, and to authenticate the client app before adding a tag to its registration.

    If you want to know how to send push notifications to specific users that have tags associated with their registrations refer to below doc link: (for Android)
    https://learn.microsoft.com/en-us/azure/notification-hubs/push-notifications-android-specific-users-firebase-cloud-messaging

    You can use tags to identify all the devices associated with a particular user.

    Check: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-tags-segment-push-message#using-tags-to-target-users

    To answer on how de-registration work?

    If you uninstall the app, the operating system of the device in question will invalidate the unique identifier associated with that app installation, and we will in turn de-register our records of that device.

    Logging out of apps on mobile devices, on the other hand, is handled by an application, not the OS. For that reason, part of logging out should include deleting any ANH registrations or installations.

    Hope this helps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.