苹果拒绝了该应用,因为Auth0 signUpLink未在Cordova InAppBrowser中打开,而是在系统浏览器(Safari)中打开

问题描述:

我们的Io​​nic 2移动应用被苹果拒绝的原因如下:

Our Ionic 2 mobile app was rejected by apple because of the following reason:

我们注意到,该用户被带到Safari登录或注册帐户,这给用户带来了糟糕的体验. 请修改您的应用,以允许用户登录或注册该应用中的帐户.

We noticed that the user is taken to Safari to sign in or register for an account, which provides a poor user experience. Please revise your app to enable users to sign in or register for an account in the app.

Auth0锁为用户提供了我们通过锁的signUpLink选项配置的注册按钮.此按钮可在应用程序外部的系统浏览器(Safari)中打开注册页面,这显然是Apple所不能接受的.

The Auth0 Lock provides the user with a sign up button that we configured through the signUpLink option of the Lock. This button opens a registration page in the system browser (Safari) outside of the application, which apparently isn't acceptable for Apple.

在我们升级到最新版本的Ionic 2(Ionic 2 beta 11)之前,该锁将打开InAppBrowser中的链接, 对Apple来说是可接受的.由于Ionic 2版本的差异,我认为这可能是一个Ionic问题.

Before we upgraded to the latest version of Ionic 2 (Ionic 2 beta 11), the lock would open the link in the InAppBrowser, which is acceptable for Apple. Because of the difference in Ionic 2 version, I imagine this could be an Ionic issue.

我确保已安装 Cordova InAppBrowser插件.它以<plugin name="cordova-plugin-inappbrowser" spec="~1.6.1" />的形式出现在我的config.xml中,当我在XCode中打开.xcproject文件时,该插件出现在Plugins文件夹中.我还使用open('https://www.google.com/, '_blank');手动使用InAppBrowser进行了测试,该打开了InAppBrowser.

I made sure I had the Cordova InAppBrowser plugin installed. It's present in my config.xml as <plugin name="cordova-plugin-inappbrowser" spec="~1.6.1" /> and when I open the .xcproject file in XCode, the plugin is present in the Plugins folder. I have also tested using the InAppBrowser manually using open('https://www.google.com/, '_blank'); which opened the InAppBrowser as it should.

关于Auth0锁的代码或注册页面的URL都没有改变.

Neither the code regarding the Auth0 Lock, nor the URL to the registration page changed.

Auth0锁定版本:10.6(也曾在10.11上尝试过,未能解决问题)
离子版本:2.1.0 操作系统:iOS

Auth0 Lock version: 10.6 (have also tried on 10.11, didn't solve the issue)
Ionic version: 2.1.0 OS: iOS

自从Ionic 2 beta 11以来,有什么改变会影响在InAppBrowser中打开链接?

What could've changed since the Ionic 2 beta 11 that would affect opening the link in the InAppBrowser?

我通过在按钮上添加onclick属性来打开window.open函数中的链接,提出了一个临时的临时解决方法:

I have come up with a dirty temporary workaround by adding an onclick attribute to the button that opens the link in the window.open function:

    this.lock.on('show', () => {
        let parent: Element = undefined;
        let intervalIndex = 0;
        let interval = setInterval(() => {
            parent = document.getElementsByClassName('auth0-lock-tabs')[0];

            if (parent) {
                let item = parent.children.item(1).children.item(0);
                item.setAttribute('onclick', `window.open('${AppSettings.registrationUrl}', '_blank'); return false;`);
                item.removeAttribute('href');

                clearInterval(interval);
            }

            if (intervalIndex == 20)
                clearInterval(interval);

            intervalIndex++;
        }, 500);
    });

通过此修改,注册链接会在InAppBrowser中打开,因此不再违反Apple的条款.

With this modification, the sign up link opens in the InAppBrowser and therefore doesn't violate Apple's terms anymore.

注意:这不是解决此问题的好方法,也不保证可以解决此问题,因为在按钮上配置此onclick属性会有延迟.

Note: this is not a good answer to this problem and is not a guaranteed fix as there is a delay on configuring this onclick attribute on the button.