5

I need registrationId from Azure. Is it possible to get the registrationId from Azure?

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {
    SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBLISTENACCESS
                                                 notificationHubPath:HUBNAME];

    [hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {
        if (error != nil) {
            NSLog(@"Error registering for notifications: %@", error);
        }
        else {
           [self MessageBox:@"Registration Status" message:@"Registered"];
        }
    }];
}

Notifications are working fine but I need registrationId from Azure to send back to server.

James Jordan Taylor
  • 1,560
  • 3
  • 24
  • 38
  • Could you solve this issue? I am confronted with the same problem. I want to send back the RegistrationId to the backend, but I just get the Apple Token. – boindiil Nov 28 '16 at 15:36
  • Have any one able to get the registration ID? – Warrior Jun 04 '17 at 19:32
  • I pored through the NotificationHub SDK code available at https://github.com/Azure/azure-notificationhubs/tree/master/iOS/WindowsAzureMessaging/WindowsAzureMessaging and found that the registration methods are all internal to the SDK class SBNotificationHub and are not exposed via the ObjC header file. Until they do that you either override the SDK header file with your own or accept that you can't have it. – James Jordan Taylor Aug 14 '18 at 18:11

1 Answers1

0

I pored through the NotificationHub SDK code available at https://github.com/Azure/azure-notificationhubs/tree/master/iOS/WindowsAzureMessaging/WindowsAzureMessaging and found that the registration methods are all internal to the SDK class SBNotificationHub and are not exposed via the ObjC header file. Until they do that you either override the SDK header file with your own or accept that you can't access the registrationId from the SDK. The methods in question are retrieveAllRegistrationsWithDeviceToken or extractRegistrationIdFromLocationUri. The latter also requires that you call composeCreateRegistrationIdUri and then registrationOperationWithRequestUri.

James Jordan Taylor
  • 1,560
  • 3
  • 24
  • 38