Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Incorrect Notification Hub creation code #169

Closed
BeatriceOltean opened this issue Feb 4, 2015 · 4 comments
Closed

Incorrect Notification Hub creation code #169

BeatriceOltean opened this issue Feb 4, 2015 · 4 comments

Comments

@BeatriceOltean
Copy link
Contributor

The code added to create the NotificationHub object has the connection string and hub name mixed up:
String connectionString = "plugintesthub";
return new NotificationHub("Endpoint=sb://plugintesthub-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=/vknTzWL7AIZ2fnI/sLZ5JJvr9C1EdbMwK86HbrCgdo=", connectionString, activity);
Notification Hub takes the hub name first and the connection string second. Plus we’re putting the hub name in the connection string variable.

@leotilli
Copy link
Contributor

leotilli commented Feb 5, 2015

Fixed on Jan 20th (8cfbd72)

And merged on Jan 28th (#113)

@kasturiswain
Copy link

Notification HUB has the following connection string in AzureServiceactivity.

String hubName = context.getString(R.string.nh_name_activity_azure_services);
String connStr = context.getString(R.string.nh_conn_str_activity_azure_services);

@leotilli
Copy link
Contributor

Now it has the correct order.

public static class NotificationHubsHelper extends NotificationsHandler {
        @Override
        public void onRegistered(Context context, String gcmRegistrationId) {
            try {
                String hubName = context.getString(R.string.nh_name_activity_azure_services);
                String connStr = context.getString(R.string.nh_conn_str_activity_azure_services);

                NotificationHub hub = new NotificationHub(hubName, connStr, context);
                hub.register(gcmRegistrationId);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onUnregistered(Context context, String gcmRegistrationId) {
            try {
                String hubName = context.getString(R.string.nh_name_activity_azure_services);
                String connStr = context.getString(R.string.nh_conn_str_activity_azure_services);

                NotificationHub hub = new NotificationHub(hubName, connStr, context);
                hub.unregister();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onReceive(Context context, Bundle bundle) {
            super.onReceive(context, bundle);
            //YOU CAN OVERRIDE THE DEFAULT IMPLEMENTATION HERE
        }
    }

@babumuralidharan
Copy link

Closing this issue since the code was corrected.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants