microsoft / msopentech-tools-for-intellij

Plugin for easy and fast development to enable developers of Android Apps to connect to Office 365 services and Azure Mobile Services, and developers of Java middleware to connect to Azure compute services
Apache License 2.0
28 stars 34 forks source link

Incorrect Notification Hub creation code #169

Closed BeatriceOltean closed 9 years ago

BeatriceOltean commented 9 years ago

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 commented 9 years ago

Fixed on Jan 20th (https://github.com/MSOpenTech/msopentech-tools-for-intellij/commit/8cfbd728316a0051ad6c5224c53bf732f48cbdfa)

And merged on Jan 28th (https://github.com/MSOpenTech/msopentech-tools-for-intellij/pull/113)

kasturiswain commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

Closing this issue since the code was corrected.