【问题标题】:iOS Safari "Add to home screen" issueiOS Safari“添加到主屏幕”问题
【发布时间】:2016-01-18 08:52:12
【问题描述】:

我有一个网络应用,使用这个元数据:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

这个应用程序是一个基于 web 的 php Silex/Symfony,启动时有一个登录会话。

我的 iPad 上有我的图标,但每次打开我的应用时,safari 总是会重新加载登录页面,即使我之前登录过。

谁能帮我解决这个问题?

// Register routes
$app->get('/', 'index.controller:indexAction')->bind('index')->value('require_authentication', true);
$app->get('/login', 'auth.controller:loginAction')->bind('login');
$app->get('/logout', 'auth.controller:logoutAction')->bind('logout');
$app->post('/auth', 'auth.controller:authAction')->bind('auth');
....


//before stack - check for user login, if not throw AccessDeniedHttpException
$app->before(function(Request $request, Application $app) {

    if ($app['request']->get('require_authentication')) {
        if (null === $user = $app['session']->get('user')) {
            throw new AccessDeniedHttpException("require auth");
        }else{ 
            $app["twig"]->addGlobal("user", $user);

        }
    }
});

此网络应用程序将仅在 iPad 上使用,因此无需为每个设备识别代码。

【问题讨论】:

  • 您需要向我们提供更多信息。把你的路由表放在这里。还将所有与识别设备相关的代码放在这里。

标签: ios symfony session web-applications safari


【解决方案1】:

/ 的路由将捕获所有请求,因此您需要 reorder them such that more specific route paths are not caught be less specific ones

定义路由的顺序很重要。将使用第一个匹配的路由,因此在底部放置更多通用路由。

这意味着您的代码应如下所示:

// Register Routes
$app->get('/login', 'auth.controller:loginAction')->bind('login');
$app->get('/logout', 'auth.controller:logoutAction')->bind('logout');
$app->post('/auth', 'auth.controller:authAction')->bind('auth');
$app->get('/', 'index.controller:indexAction')->bind('index')->value('require_authentication', true);  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    • 1970-01-01
    • 2018-10-27
    • 2012-04-24
    相关资源
    最近更新 更多