Android глубокая ссылка не работает, когда приложение закрыто в перенаправлении - PullRequest
0 голосов
/ 10 апреля 2020

Я создал глубокую ссылку в моем AndroidManifest.xml:

<activity android:name=".DeeplinkActivity">
    <intent-filter android:label="deeplink">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="deep-link1"
            android:scheme="mydeeplink" />
    </intent-filter>
</activity>

И мой фреймворк flask перенаправляет эту глубокую ссылку, щелкая URL-адрес.

Вот мой сценарий, который Глубокая ссылка не работает:

  • Закройте все приложения или принудительно закройте мое приложение.
  • Нажмите мой указанный c URL в WhatsApp или вставьте его в Chrome Браузер , и он будет перенаправлен на мою глубокую ссылку (mydeeplink: // deep-link).
  • Перенаправление не работает, и глубокая ссылка не откроет мою Activity.
  • Я попробую вышеупомянутое действие снова и Это работает , DeeplinkActivity открывается.

Я не понимаю, почему глубокая ссылка не открывается в в первый раз ? Есть ли проблема с перенаправлением на моем сервере, или у моего приложения (или ОС) есть проблема?

Вот мой метод перенаправления в flask:

def redirect(location, code=302, Response=None):
    """Returns a response object (a WSGI application) that, if called,
    redirects the client to the target location. Supported codes are
    301, 302, 303, 305, 307, and 308. 300 is not supported because
    it's not a real redirect and 304 because it's the answer for a
    request with a request with defined If-Modified-Since headers.

    .. versionadded:: 0.6
       The location can now be a unicode string that is encoded using
       the :func:`iri_to_uri` function.

    .. versionadded:: 0.10
        The class used for the Response object can now be passed in.

    :param location: the location the response should redirect to.
    :param code: the redirect status code. defaults to 302.
    :param class Response: a Response class to use when instantiating a
        response. The default is :class:`werkzeug.wrappers.Response` if
        unspecified.
    """
    if Response is None:
        from .wrappers import Response

    display_location = escape(location)
    if isinstance(location, text_type):
        # Safe conversion is necessary here as we might redirect
        # to a broken URI scheme (for instance itms-services).
        from .urls import iri_to_uri

        location = iri_to_uri(location, safe_conversion=True)
    response = Response(
        '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n'
        "<title>Redirecting...</title>\n"
        "<h1>Redirecting...</h1>\n"
        "<p>You should be redirected automatically to target URL: "
        '<a href="%s">%s</a>.  If not click the link.'
        % (escape(location), display_location),
        code,
        mimetype="text/html",
    )
    response.headers["Location"] = location
    return response

Я не изменился стандартная конфигурация flask.

Спасибо за помощь.

...