Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Azure Notification hub unregister

I'm having a problem with unregistering notification hub from Azure.

I'm using method unregister() like this :

gcm = GoogleCloudMessaging.getInstance(getApplicationContext());

String connectionString = "xxx";
hub = new NotificationHub("xxx", connectionString, getApplicationContext());

try {
    gcm.unregister();
    hub.unregister();
    Log.d("GCM","Unregister");
} catch (IOException e) {
    e.printStackTrace();
} catch (Exception e) {
    e.printStackTrace();
};

I don't get any exception in this code, but I'm still getting push notification. Any help will be apreciated. Thanks in advance.

like image 523
Fahmi Sidik Avatar asked Mar 24 '15 10:03

Fahmi Sidik


People also ask

How do I register my device in Azure notification hub?

You just need to log into Azure portal, choose your App Service, then click "Settings > Push" to configure your Notification Hub. For your Xamarin.

What is Azure notification hub service?

Azure Notification Hubs is a massively scalable mobile push notification engine for quickly sending millions of notifications to iOS, Android, Windows, or Kindle devices, working with APNs (Apple Push Notification service), GCM (Google Cloud Messaging), WNS (Windows Push Notification Service), and more.

What is Azure notification hub namespace?

Azure Notification Hubs has two resource levels: hubs and namespaces. A hub is a single push resource that can hold the cross-platform push information of one app. A namespace is a collection of hubs in one region. Recommended mapping matches one namespace with one app.

Which dependency managers is the notification hubs SDK available through?

The Azure Notification Hubs SDK also supports the Swift Package Manager. To integrate, use the following steps: From the Xcode menu click File > Swift Packages > Add Package Dependency.


1 Answers

You shouldn't unregister from GCM.

Why you should rarely unregister

You should only need to unregister in rare cases, such as if you want an app to stop receiving messages, or if you suspect that the registration ID has been compromised. In general, once an app has a registration ID, you shouldn't need to change it.

In particular, you should never unregister your app as a mechanism for logout or for switching between users, for the following reasons:

  • A registration ID isn't associated with a particular logged in user. If you unregister and then re-register, GCM may return the same ID or a different ID—there's no guarantee either way.

  • Unregistration may take up to 5 minutes to propagate.

  • After unregistration, re-registration may again take up to 5 minutes to propagate. During this time messages may be rejected due to the state of being unregistered, and after all this, messages may still go to the wrong user.

More info here: http://developer.android.com/google/gcm/gcm.html#unreg-why

Since you are using Azure Notification Hub, you just need to delete registration from there, not from GCM.

like image 139
WriteEatSleepRepeat Avatar answered Sep 27 '22 18:09

WriteEatSleepRepeat