Closed BeatriceOltean closed 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)
Azure Service Activity has the following code in it. 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);
Yes, and its part of the onRegistered event handler, so it's the expected behavior.
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
}
}
Closing this since the template code has been corrected.
The AzureServicesActivity has this code in it: NotificationHub notificationHub = NotificationHubsHelper.getNotificationHub(this); notificationHub.register("GCM_REGISTRATION_ID”); Calling getNotificationHub kicks off an async task (inside NotificationsManager) which handles registering with GCM and getting the registration ID. We can’t call notificationHub.register here because we won’t necessarily have the ID back yet. More so we’re just passing in “GCM_REGISTRATION_ID” instead of an actual ID. I’d suggest altering the NotificationHubsHelper class so that it implements the onRegistered method and has a static reference to the instance of the NotificationHub object it can use to pull out the registration ID. You can see an example of this in a gist here: https://gist.github.com/ChrisRisner/796fb9d1c6ade285f489