Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

Mobile javascript; how to launch an external browser like Chrome with an URL

  • 1.  Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu December 21, 2023 05:46 AM
    Edited by Vincent Wanders Thu December 21, 2023 05:53 AM

    I would like to launch an external browser with any webpage from the appCustomization.js

    window.open is not what i am looking for (that one does really Not work in Maximo mobile).

    Maybe I have to do something with Intent. Ofcourse i tried a few things, but also no succes.

    Have anyone an idea. Because it is really important for the customer to get it working!

    Some code I have is:

    <a 
      href="intent:https://example.com#Intent;end" 
      target="_blank">
      Open Browser
    </a>

    Is there any way to get this into mobile? Through the app.xml maybe?

    ------------------------------
    Vincent Wanders
    ------------------------------



  • 2.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Fri December 22, 2023 08:09 AM

    Your code snippet is HTML which you cannot directly interact with in MAF (Maximo Application Framework). To open a link outside of the container on mobile (while still supporting the web role based application scenario), you want to do something like below in your AppCustomizations.js and tie the openGoogle() to an event like an on-click on a button in the app.xml. 

    import {Browser} from '@maximo/maximo-js-api';
       openGoogle()
       {
         let url="https://google.com"
         if(this.app.device.isMaximoMobile)
         {
           try{
             window.cordova.InAppBrowser.open(url, "_system", 'location=yes');
           }catch(error)
           {
             Browser.get().openURL(url);
           }
         }else{
           Browser.get().openURL(url);
         }
       }


    ------------------------------
    Steven Shull
    ------------------------------



  • 3.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Sat December 23, 2023 02:35 PM

    Thnx, Steven!

    This is working! The whole black screen I posted sometime ago is solved.

    I had already rebuild the attachment functionality in Techmobile.
    Only thing I had to do was past your code and put a Sharepoint URL in it.

    A question I have; Is there any knowledge base for this sort imports/code?

    Because there is a whole world out there and it is hard getting somewhere.
    I did spent many hours on the internet (and chatgpt) and I didn't find anything like this solution.

    Happy holidays!



    ------------------------------
    Vincent Wanders
    ------------------------------



  • 4.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Tue December 26, 2023 07:23 AM

    In 8.11, we embedded a subset of a wiki we have internally into the docker configuration image (when you click the help icon and choose Developer Documentation). The goal is to cover topics like this either in that wiki or in the IBM Docs or IBM Community (IBM Docs & IBM Community linked from here: https://www.ibm.com/support/pages/node/6408032 ). I don't think, however, that this topic is documented anywhere yet. I'll try and get it documented in the wiki & IBM community when I get a chance. 



    ------------------------------
    Steven Shull
    ------------------------------



  • 5.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu January 18, 2024 02:31 PM

    Hi Vincent,

    Can you share how did you attach or trigger the above suggested code by steven in mobile app.xml in any mobile app?



    ------------------------------
    Ritesh Ranjan
    ------------------------------



  • 6.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu January 18, 2024 03:25 PM

    Hi Vincent,

    I tried and it is working with On-Click function with a button.



    ------------------------------
    Ritesh Ranjan
    ------------------------------



  • 7.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu January 18, 2024 03:32 PM
    Edited by Ritesh Ranjan Thu January 18, 2024 03:52 PM

    Hi @Steven Shull,

    This is a very nice suggestion. I am trying to make use of this to add LOGOUT click in RBA app with this URL - https://maximohost/maximo/webclient/login/logout.jsp

    and it seems to be working. It opens a NEW TAB and shows up Maximo core login page.

    I also noticed that session entry is getting removed from maxsession table and logout entry is also getting written into LOGINTRACKING table.

    Do you think that there could be any side effects or any other kind of harm if I use the above approach?

    Please advise if any.

    Additionally, I was going through Browser.js file in MAF container to see what all functions are available. I was trying to find if there is any other function which will open the URL in the SAME TAB instead of NEW TAB in the browser.

    Please advise on this too if feasible.

    Note: At the moment, I am not sure what would be the behavior in SAML SSO environment!!

    Thanks in Advance.



    ------------------------------
    Ritesh Ranjan
    ------------------------------



  • 8.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu January 18, 2024 04:22 PM

    There is a logout controller within Mobile (Navigator).

    import { log } from "@maximo/maximo-js-api";
    const TAG = "LogoutController";

    class LogoutController {
      pageInitialized(page, app) {
        this.app = app;
        this.page = page;
        //Hide navigator menu
        const event = new Event('CLOSE-NAVIGATOR');
        window.dispatchEvent(event);
        /* istanbul ignore next */
        try {
             document.getElementById('navigator').getElementsByTagName('header')[0].style.visibility= 'hidden';
        } catch (err){
            log.e(TAG,'Unable to hide navigator footer')
        }
       
        log.t(TAG, "pageInitialized : is initialized");

      }
    }

    export default LogoutController;
    Question could be how to call this function from an app like Techmobile through App.xml or a function within AppCustumizations.js?


    ------------------------------
    Vincent Wanders
    ------------------------------



  • 9.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Thu January 18, 2024 04:48 PM
    Hi Vincent,

    From RBA, navigator app is not accessible so that's why I was looking for a custom log out click feature. Also I did not deep dive into navigator app. 

    Also, I just figured out the part for opening that URL in a same tab instead of new tab. 

    Now the info you shared on logout controller is interesting. Though I am not sure how to call this function in RBA via app.xml.

    Just a thought.. what if we copy the controller file itself in techmobile folder and also add "user-profile-enabled=" true" in techmobile app.xml?

    will it work then? 


    'The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com'

    Internal - General Use






  • 10.  RE: Mobile javascript; how to launch an external browser like Chrome with an URL

    Posted Fri January 19, 2024 01:16 AM

    I know that logging out is not available within RBA.

    Btw. If you only stay within RBA, window.open should probably also work.
    What I would like to hear from IBM is how to use the functions they already made as a "client user/consultant programmer".

    I did put the code in the AppCustomizations.js btw and played around with it, and it did not work.

    I know it was a longshot, and it is in the same category as the Add Attachment post from me yesterday.

    Hopefully somebody can explain us how to do it. 

    Because for me it is important. I have a customer who wants to have quite some modifications on Mobile to get Mobile to work for them.

    Anyway, I am happy with a forum like this one.



    ------------------------------
    Vincent Wanders
    ------------------------------