June 27, 2015

InAppBrowser in Oracle MAF using Cordova plug-in

This post is to show how to implement In-app browser in MAF using Cordova plugin.

If you have a url in the app, on click of the url, the URL will be open in a browser but if you want to come back to the app, you have to open your app tray and select the app. If you implement in-app browser, the url will be opened in a custom browser in the app itself, and you can see a button like "Done" on the browser. On click of that, you can return to the app.

Below is the procedure to develop the in-app browser using Cordova plugin.
  • Download the zip file of the project from Github and unzip it
  • Create a folder with the name plugins in ViewController project in the app
  • Copy file plugin.xml and folders www, src from the above Github project to the plugins folder
  • Open maf-application.xml file and select Plugins 
  • Under "Additional Plugins", add the plug in. See below screen for your reference

  • Write the below code in a java method and assign that method as an action or action listener to an action component in your page
          String urlToPen = "http://myfusionlearnings.blogspot.com";
          AdfmfContainerUtilities.invokeContainerJavaScriptFunction(        
         AdfmfJavaUtilities.getFeatureId(),
       "function(){cordova.InAppBrowser.open('"+urlToPen+"','_blank',              
        'location=no,toolbarposition=top,clearcache=yes');}", new Object[] {});

No comments:

Post a Comment