0

Introduction

I'm working on a backend which is used by iOS and Android mobile apps and have decided to use Azure Notification Hubs for push notifications. It is written in .NET and uses device registration from a backend (Registration).

User is able to use same application on multiple devices at the same time and requirements are that users should be able to receive notifications on all devices. There is also possibility that multiple users will use app on the same device - authentication is done using username and password.

Registrations are saved in DB table which stores:

  • registrationId
  • platform
  • reference to user

This makes it possible for the same user to receive notifications on multiple devices.

Registration

Registration is done in the following way on the iOS device:

  1. App is started
  2. PNS handle is received from APNS (token)
  3. Username and password are entered
  4. App asks for RegistrationId from backend
  5. RegistrationId is saved to local storage
  6. Registration is performed using RegistrationId, Handle and Platform parameters which are sent to Web API endpoint
  7. Tag "username:test1" is added so notification can be sent to specific user

Problem(s)

I've noticed that PNS Identifier is same for two (or more) registrations (please see screenshot). Developer which is working on the iOS app pointed to the following question: Obtain NEW Apple device token?

enter image description here

Is it valid to have same PNS Identifier for multiple installations provided that I have unique tags?

If there are multiple duplicates of PNS Identifier application would display multiple notifications (notifications are filtered by tag "username")?

Should the PNS Identifier be unique for app, device or user?

Community
  • 1
  • 1
dpihac
  • 13
  • 2
  • 8
  • Is it a production or a test system? (Looks like the latter.) You have two different tags associated with those two different registrations sharing the single PNS handler. If you're storing Notification Hubs registration ID in the local storage using a dictionary where keys are user names, then it's possible that you were testing your app under two different users and during the second pass the `username:test1` registration didn't get picked up because you were logged in as `username:test2`, so you re-registered the same device under a different user name. – Nikita R. Aug 19 '16 at 16:28
  • @Nikita G. It's a test system and the registration wasn't done on the phone - I was using Postman to send requests to the backend API. I'm not sure how the Azure's NH RegistrationId should be stored on the phone. Idea was to have it stored as a dictionary, just like you've mentioned in the comment. – dpihac Aug 19 '16 at 18:18
  • So what's the problem then? It looks like you submitted two separate requests to create registrations with different tags, but the same PNS handle. Which resulted in two separate registrations. Is it unexpected to see what described you then? – Nikita R. Aug 19 '16 at 18:41
  • @NikitaG. It's what I expected, but I not sure that's good way to go. I haven't found in documentation any recommendations or mention of registrations with same PNS Identifier. Apple's APNS generates token only once and I don't know about GCM yet. So if the token is generated per application installation on that device (APNS, GCM probably does the same) then I don't have much options. – dpihac Aug 20 '16 at 07:00
  • Regarding GCM, I believe FirebaseInstanceId tokens are refreshed periodically. The recommended Android practice is for the device to respond to Firebase updates as they come. See this [q & a](http://stackoverflow.com/questions/37671380/what-is-fcm-token-in-firebase) and search for sendRegistrationToServer. – Howard Hoffman Sep 06 '16 at 20:57
  • Thanks @HowardHoffman I've come up with the solution which seems to be working for both GCM and APNS. Thanks for the link ;) – dpihac Sep 07 '16 at 09:52
  • @dpihac what solution did you go with finally? – Daniel Kotin May 24 '17 at 11:05
  • This was quite a while ago, but for anyone new to this comment thread, the discussion is outdated due to the concept of installations where we now are able to provide an installation id (registration id) of our choosing, simplifying the process a bit. – DisplayName Feb 10 '22 at 09:41

0 Answers0