This discussion is archived
9 Replies Latest reply: Jan 9, 2013 3:29 AM by Damir Vadas RSS

How to determine device (desktop or mobile) connected to Apex

737189 Newbie
Currently Being Moderated
Hi!
I have developed many triggers that fire after login. One of them to redirect app to user defined start page.
Now when mobile apps are introduced (Apex 4.2), many things has to be changed in mine logic.
User might have one startup page for mobile and other one for desktop app.
So I have to implement the same logic as it is built in Apex (when user go to app to be redirected to desktop or mobile login page).

Mine question is how to achieve something in PLSQ. Like this code:
IF desktop_ver=1 then 
  :STARTUP_PAGE = 123;
ELSIF desktop_ver=2 THEN
  :STARTUP_PAGE = 1123;
ELSE
   :STARTUP_PAGE = 1;
END IF;
Where desktop_ver is something (variable, function or anything else, "1"=desktop, "2"=mobile ... "something else" as not recognized device) that must be able to recognize previously mention device (mobile or desktop) that called the page.

Rg
Damir

Edited by: Damir Vadas on Jan 7, 2013 3:17 AM
  • 1. Re: How to determine device (desktop or mobile) connected to Apex
    928468 Explorer
    Currently Being Moderated
    Hi Damir,

    you could use a before header branch on the first page (page 1?) after login to directly redirect to different "start pages".
    If you could somehow pass some variable from the login page, containing the browser info, there could be two different branches with PL/SQL conditions like you described in your post.

    Edit: This might be helpful to get the browser info:

    Re: How to prevent old-browser user from login

    Hope this helps somehow...

    Thanks
    Sandro

    Edited by: sakra on 07.01.2013 04:50
  • 2. Re: How to determine device (desktop or mobile) connected to Apex
    737189 Newbie
    Currently Being Moderated
    Sakra,
    Thx for your suggestion but "page processing" is just some of the things that might differ in desktop/mobile run time (I have some loging, changing behaviour of some items, and many other things that I'd might have in future).

    So I'd like to get something that is implemented in Apex core (default Apex app url-without page, just app_id in url, knows how to redirect to desktop/mobile page).
    So I'd like to understand how is that working.

    I think there must be something ... "PL/SQL-able" to get that information.

    According mine previous post I'm looking for something like (suppose that "OWA_UTIL" is that package ... jsut suppose I do not say this is true):
    l_device_info:=OWA_UTIL.get_device_info;
    IF l_device_info='desktop' THEN
      ...
    ELSIF l_device_info='mobile' THEN
      ...
    ELSE
      ...
    END IF;
    This will help me a lot to implement mine logic in many places (whenever it is possible to differ mobile/desktop( screening or process approach.

    Hope now is more clear.

    Edited by: Damir Vadas on Jan 7, 2013 5:52 AM
  • 3. Re: How to determine device (desktop or mobile) connected to Apex
    Damir Vadas Newbie
    Currently Being Moderated
    Am I missing something very obvious or this is hidden part of Apex?
    THX
  • 4. Re: How to determine device (desktop or mobile) connected to Apex
    Patrick Wolf Employee ACE
    Currently Being Moderated
    Hi Damir,

    as soon as APEX has detected the user interface and redirected you to the related login page, you can use the package apex_page to determine the user interface of the current page. It has the following APIs.
    --==============================================================================
    -- Returns TRUE if the current page has been designed for Desktop browsers.
    --==============================================================================
    function is_desktop_ui return boolean;
    --
    --==============================================================================
    -- Returns TRUE if the current page has been designed for smartphone devices
    -- using jQuery Mobile.
    --==============================================================================
    function is_jqm_smartphone_ui return boolean;
    --
    --==============================================================================
    -- Returns TRUE if the current page has been designed for tablet devices
    -- using jQuery Mobile.
    --==============================================================================
    function is_jqm_tablet_ui return boolean;
    --
    --==============================================================================
    -- Returns the UI type for which the current page has been designed for.
    --==============================================================================
    function get_ui_type return varchar2;
    Is that what you are looking for?

    Regards
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf
  • 5. Re: How to determine device (desktop or mobile) connected to Apex
    Damir Vadas Newbie
    Currently Being Moderated
    Patrick,
    Thank you very much for this info. This is very progressive point. I think I could do manage many things with your answer.

    But frankly Id like to get more detail about your part:
    *...  as soon as APEX has detected the user interface*

    How really Apex detect that? Where is this part implemented if not too hidden?

    If this code might be reviewed that will be a gold for me ... and I think many Apex developer.

    Rg and all the best in 2013.
    Damir Vadas
    http://damir-vadas.blogspot.com
  • 6. Re: How to determine device (desktop or mobile) connected to Apex
    Christian Neumueller Expert
    Currently Being Moderated
    Hi Damir,

    that code is embedded in the part of the engine which sets up the session at the beginning of request processing. It basically examines the USER_AGENT http header to detect the user interface. I can not show you the Apex source code, but there are other frameworks in various languages (some of them open source, e.g. Categorizr) that do similar things:

    http://en.wikipedia.org/wiki/Mobile_device_detection

    Our device detection code runs when the URL does not contain a page id. It loops over all user interfaces that are installed in the app and redirects to the home page of that one which can be automatically detected. If there is an ambiguity, Apex renders a built-in device selection page. We also thought about client-side detection and the hooks are in place (wwv_flow_ui_types.autodetect_js_function_body). That is not yet implemented, though.

    Regards,
    Christian
  • 7. Re: How to determine device (desktop or mobile) connected to Apex
    Damir Vadas Newbie
    Currently Being Moderated
    Christian,
    THX for this info.

    Find this case closed.

    THX again.
    Rg,
    Damir Vadas
    http://damir-vadas.blogspot.com
  • 8. Re: How to determine device (desktop or mobile) connected to Apex
    Tom Petrus Expert
    Currently Being Moderated
    Scott Wesley and Christian Rokitta also made a venture into categorizr territory through plsql: http://www.grassroots-oracle.com/2012/11/categorizr-for-apex-extended.html
    Just interesting!
  • 9. Re: How to determine device (desktop or mobile) connected to Apex
    Damir Vadas Newbie
    Currently Being Moderated
    Tom,

    This is magnificent work!

    Thank you for sharing this info ... and all the regards to author as well.
    Damir Vadas
    http://damir-vadas.blogspot.com

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points