Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device is unregistered but still getting notification #5

Open
GokhanArik opened this issue Jul 6, 2016 · 11 comments
Open

Device is unregistered but still getting notification #5

GokhanArik opened this issue Jul 6, 2016 · 11 comments
Labels
registration-flow Pertains to the older registration based namespace.

Comments

@GokhanArik
Copy link

Hi,

There is a common problem I saw around. Sometimes a device is registered multiple times. When you unregister it doesn't unregister all registrationIDs associated with the device. It just deletes one.

The scenario to recreate the issue is that if the user uninstalls our app, we won't be able to unregister their device. When they install again they will be registered twice. If we unregister latest registrationId, the first one still be in the hub.

@nikitag-ms
Copy link

Is there a chance that somehow the same device token gets re-registered over and over again? Then, indeed, if you just remove one registrations, the others will still stay there.

There's a REST API (corresponds to getRegistrationsByChannel SDK method) to get all registrations by token. You could use that to see whether there're registrations associated with the device left.

@GokhanArik
Copy link
Author

I can look at registrations using Visual Studio and delete duplicate ones also. However, for an app that is in production that won't solve the problem. I don't want to write a script to check and remove duplicate entries. Azure SDK should handle that. What do you think?

@nikitag-ms
Copy link

I don't want to write a script to check and remove duplicate entries. Azure SDK should handle that.

Totally agree with that. That's why I was trying to understand why are there duplicates and suggested that maybe the same device token keeps re-registered and gets different registration ids. Are you sure that you only register a single device only once?

@GokhanArik
Copy link
Author

No, as I said a device gets registered multiple times. Here is a possible scenario,

  1. A user installs the app and gets registered to Azure.
  2. The user deletes the app. (His registration id is not removed from Notification Hub)
  3. The user installs the app again and gets registered to Azure.

Now the user will have two registration IDs for the same device. In production, it might be an edge case. However, when we are testing we keep installing/uninstalling the app and it slows down our testing process.

I think part of the problem is that Google Cloud Messaging is always assigning the same id for the device, so it gets registered multiple times. In my opinion, Azure shouldn't allow duplicate entries for the same PNS handle or make it optional in Notification Hub Settings.

@GokhanArik
Copy link
Author

@nikitag-ms Is there any solution to that?

@nikitag-ms
Copy link

Can you store the original registrationId in the local storage that can persist re-installation and then call CreateOrUpdateRegistration?

@GokhanArik
Copy link
Author

That's what I'm planning to do

@albfan
Copy link

albfan commented Jan 26, 2017

I am in the same situation.

Works well

  1. app login register a device with some tags
  2. app logout unregister device correctly

Works wrong

  1. app register a device with some tags
  2. app is closed by user and it is not unregistered
  3. app register a device with other tags (fail 401)
  4. app tryes to unregister all tags with same pnshandle (401 fails)

After receive a 401 (unauthorized) I'm planning to do a unregisterall call, but first task that method do is to refresh pnshandle that gives another 401 so no pnshandle is removed.

I guess the problem is in refreshing registrations.
https://github.com/Azure/azure-notificationhubs/blob/master/Android/notification-hubs-sdk/src/main/java/com/microsoft/windowsazure/messaging/NotificationHub.java#L259

What means exactly 401? I was planning to use directly REST API, but if this can be solved would be great

@pilondev
Copy link

someone can solve the problem ? i have the same issue 👎

@VinSmile
Copy link

VinSmile commented Oct 6, 2017

In .NET Framework. When adding new registration, you can search for all existing ones that uses the same GCM handle
var oldRegistrations = await hub.GetRegistrationsByChannelAsync(registration.Handle, 10);

@Alessar Alessar transferred this issue from Azure/azure-notificationhubs Mar 5, 2019
@marstr marstr added the registration-flow Pertains to the older registration based namespace. label Aug 11, 2020
@eric-labelle
Copy link

eric-labelle commented Oct 5, 2020

This issue seems to still be valid. The number of registered devices keeps increasing even if I'm only testing the sdk with one device (installing/uninstalling a lot) and can't see a way to see which device are registered from the azure portal, only a number refreshing daily which is pretty useless in this case trying to debug which devices are still registered and receiving the notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
registration-flow Pertains to the older registration based namespace.
Projects
None yet
Development

No branches or pull requests

7 participants