由于 Firebase phone 身份验证,App Store 被拒绝

App Store rejection due to Firebase phone auth

我们的应用程序使用 Firebase phone 身份验证。由于需要推送,App Store 审核拒绝了该应用:

Guideline 4.5.4 - Design - Apple Sites and Services

We noticed that your app requires push notifications in order to function.

Specifically, we noticed if the Push Notifications setting was not enabled on our device, we encountered an error message after entering our phone number within the app.

Next Steps

Push notifications must be optional and must obtain the user's consent to be used within the app.

他们还附上了描述 Firebase 错误“需要为应用程序设置远程通知和后台获取 [...]”的屏幕截图

Firebase 文档指出,phone 身份验证功能绝对需要 APNs 通知:
https://firebase.google.com/docs/auth/ios/phone-auth

To use phone number authentication, your app must be able to receive APNs notifications from Firebase. When you sign in a user with their phone number for the first time on a device, Firebase Authentication sends a silent push notification to the device to verify that the phone number sign-in request comes from your app. (For this reason, phone number sign-in cannot be used on a simulator.)

然而,App Store 审查指南指出,应用程序运行不需要推送通知:https://developer.apple.com/app-store/review/guidelines/

4.5.4 Push Notifications must not be required for the app to function, and should not be used for advertising, promotions, or direct marketing purposes or to send sensitive personal or confidential information.

用户需要先登录才能使用该应用程序(该应用程序是关于向您的客人发送数字 GIF 邀请和分享照片),这就是为什么应用程序运行基本上需要推送通知,如果标志在方法中是 Firebase phone auth.

我们已经对应用程序进行了大量测试,当启用推送通知时,身份验证工作没有问题(在真实设备上,无论是在生产环境下的分发 Ad Hoc 构建还是在沙盒环境下的开发构建)。

想想看,App Review 团队是如何禁用推送通知的?通知中心设置不会停止实际推送,它只是不显示它们。 我们已经在关闭此设置的情况下进行了测试,并且 firebase phone 身份验证工作正常,推送仍按预期进行。

我对这个问题感到非常惊讶,因为 Firebase 是一个巨大的服务提供商。还有其他人遇到过这个问题吗? 是否有计划删除 phone 身份验证的 APNs 要求?是否有其他方法可以在不推送的情况下使用 Firebase phone 身份验证?

我联系了 Firebase 支持,以下是摘录:

In terms of the concern around users disabling push notifications - Disabling push notification for the app by the user does not normally prevent users from signing in using their phone number with Firebase Auth. Our requirement is that the app must set up and enable push notification, not the user. Regardless of if the user accepts or declines your app's push notification prompt phone auth will continue to work since we use silent pushes that don't require any action from the user.

我进一步研究发现,即使用户明确禁用推送通知,静默推送通知确实会到达设备。要禁用静默推送通知,您需要转到“设置”->“您的应用程序”->“后台刷新”以禁用它。参见

因此您可以告诉 App Store 审核团队您的登录只有在启用后台刷新时才有效。我不认为这违反了他们的条款。

编辑

经过一些测试,phone 身份验证似乎可以在禁用后台刷新时工作。但是,它对我有用,因为 Firebase 已经可以访问我的 APNS 设备令牌。我没有找到解除我的设备令牌与 Firebase 的关联的方法——他们没有为此提供 API。不幸的是,这使得无法测试新用户在执行 phone 身份验证之前禁用后台刷新和远程通知的情况,我认为这可能是错误的原因。

编辑 2

我可以确认,在全新安装我们应用程序的全新设备上,如果您禁用后台刷新,那么 Firebase Phone 身份验证将不起作用。启用后,它将再次运行。

原因是如果用户手动禁用后台刷新和通知设置,SDK 可能会调用 [[UIApplication sharedApplication] registerForRemoteNotifications],系统会忽略该调用。

遗憾的是,在 Firebase 发布不需要 APN 的新 SDK 之前,没有解决方法。

UPD:Firebase 4.2.0 已经推出,解决了这个问题。您需要添加您的反向客户端 ID,它看起来像这样:com.googleusercontent.apps.123456-abcdefg99 到 Info.plist 中的 URL 方案,您就设置好了。

To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key.


Firebase 支持已确认此错误并给出了对此问题的响应:

to me
Thank you for the detailed information Leet. This is indeed an odd situation, and our Phone Auth engineers are taking a look. I'll get back to you as soon as I have an answer.

Best,
Jeff


to me
Hi Leet,

Our engineers are working internally on a long-term fix for this, but in the meantime, would like to meet with you to see if we can figure out a workaround.

看来 Firebase phone auth / Firebase UI 中确实存在错误。

这里是 Firebaser。正如 Leetmory 所述,我们已经发布了更新的 Firebase Auth SDK 4.2.0,有望解决这些问题。

此问题是由于 Firebase Auth SDK 使用 APN 来验证请求 - 这是为了最大限度地降低垃圾短信滥用或类似行为的风险。验证使用静默 APNs 通知,因此 iOS 8 及更高版本不需要用户明确同意。然而,如果 APNs 被完全禁用,这仍然会失败,就像在这个审查案例中一样。

4.2.0 版本引入了在 SFSafariViewController(或旧版 iOS 的 webview)中使用 reCAPTCHA 提示的功能,以防止在 APN 不可用时被滥用。我们不希望这种情况经常发生,但它解释了这里遇到的异常状态。它还支持在模拟器上测试 Firebase Phone Auth!

您会注意到 verifyPhoneNumber 方法中有一个新的 uiDelegate 参数。在大多数情况下,您不需要使用它,但它是回退验证的一部分。

如果您还没有做的话,您需要做的是将 REVERSED_CLIENT_ID(来自 GoogleService-Info.plist)添加为自定义 URL 方案。这将允许 reCAPTCHA 视图对您的应用进行 return 验证。

不过在当前版本中有一个陷阱需要注意:

  1. verifyPhoneNumber 的回调中,您需要使用 DispatchQueue.main.async {} 重新分配到主线程 - 这将在下一版本的 Firebase Auth 中修复!

除此之外,一切都应该正常进行!我们绝对建议尽可能支持静默推送,以确保最佳的用户体验。

如需完整演练,请参阅完整的 Phone Auth developer guide