【问题标题】:How to get registrationId from Azure notificationhub in iOS如何从 iOS 中的 Azure 通知中心获取registrationId
【发布时间】:2016-12-31 12:12:28
【问题描述】:

我需要 Azure 的registrationId。是否可以从 Azure 获取registrationId?

- (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"];
        }
    }];
}

通知工作正常,但我需要 Azure 的registrationId 发送回服务器。

【问题讨论】:

  • 你能解决这个问题吗?我面临同样的问题。我想将 RegistrationId 发送回后端,但我只是获得了 Apple Token。
  • 有没有人能拿到注册ID?
  • 我仔细研究了github.com/Azure/azure-notificationhubs/tree/master/iOS/… 提供的 NotificationHub SDK 代码,发现注册方法都是 SDK 类 SBNotificationHub 内部的,并没有通过 ObjC 头文件公开。在他们这样做之前,你要么用自己的覆盖 SDK 头文件,要么接受你不能拥有它。

标签: ios azure apple-push-notifications azure-notificationhub


【解决方案1】:

我仔细研究了https://github.com/Azure/azure-notificationhubs/tree/master/iOS/WindowsAzureMessaging/WindowsAzureMessaging 提供的 NotificationHub SDK 代码,发现注册方法都是 SDK 类 SBNotificationHub 内部的,并且没有通过 ObjC 头文件公开。在他们这样做之前,您要么用自己的覆盖 SDK 头文件,要么接受您无法从 SDK 访问registrationId。有问题的方法是retrieveAllRegistrationsWithDeviceTokenextractRegistrationIdFromLocationUri。后者还要求您先调用composeCreateRegistrationIdUri,然后再调用registrationOperationWithRequestUri

【讨论】:

    猜你喜欢
    • 2019-06-25
    • 2018-05-04
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 2023-03-28
    • 2018-11-09
    • 2021-08-03
    相关资源
    最近更新 更多