如何从 iOS 应用程序中获取 HockeyApp 用户 email/id?

How to get HockeyApp user email/id from within iOS app?

我让我的 HockeyApp 用户使用他们的电子邮件地址进行身份验证,如 in the HockeyApp documentation 所述。

如何从应用程序中获取用户的电子邮件(或 ID、或姓名)?

有些属性似乎包含这些值,但它们似乎是 write-only,并且总是 return 为 nil:(docs)

[BITHockeyManager sharedHockeyManager].userEmail
[BITHockeyManager sharedHockeyManager].userName
[BITHockeyManager sharedHockeyManager].userID

header 文档对 "see also" this method 说:

 [BITHockeyManagerDelegate userEmailForHockeyManager:componentManager:]

但我找不到从哪里获得 BITHockeyBaseManager 类型的 object。

您上面提到的属性以及 BITHockeyManagerDelegate 中的委托方法用于使用有关您的用户的其他元数据来丰富崩溃报告和反馈消息。

身份验证过程中使用的电子邮件地址安全地保存在 iOS 钥匙串中,应用程序开发人员通常不容易访问。
我的立场是正确的:实际上,有一个 public API 正是为了这个目的,[[BITHockeyManager sharedManager].authenticator publicInstallationIdentifier]。 另请查看 documentation or the actual code.

在应用中任意位置获取用户电子邮件的示例:

NSString *email = BITHockeyManager.sharedHockeyManager.authenticator.publicInstallationIdentifier;

请注意,这将 return 用户电子邮件地址 (kBITAuthenticatorUserEmailKey) 或 ID 代码 (kBITAuthenticatorIdentifierKey)设置您的身份验证器。要使用电子邮件身份验证进行设置,我使用了 BITAuthenticatorIdentificationTypeHockeyAppEmail。这是我的 AppDelegate 中的 HockeyApp 代码:

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"<#App id#>" delegate:self];
[[BITHockeyManager sharedHockeyManager].authenticator setAuthenticationSecret:@"<#App Secret#>"];
[[BITHockeyManager sharedHockeyManager].authenticator setIdentificationType:BITAuthenticatorIdentificationTypeHockeyAppEmail];
[[BITHockeyManager sharedHockeyManager] startManager];
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation];