-1

Trying to open another app within mine (hybrid) using mobilefirst 7.0. Nothing happens when i click either link. In a mobile browser link #2 opens up a webpage. But that's not what I want. Looking to open up facebook within my app for this example. Thanks.

Enter a package name: <input type="text" value="com.SFStaff" id="packageName"/>
<button onclick="openExternalApp()">Open External Application</button>
<script>
function openExternalApp() {
    var parameter = null;
    if (WL.Client.getEnvironment() == WL.Environment.ANDROID) {
        parameter = $('#packageName').val();
    }

    cordova.exec(onSuccess, onFailure, "OpenExternalAppPlugin", "openApp", [parameter]);
}

function onSuccess() {
    WL.Logger.info("App successfully opened");
}

function onFailure() {
    WL.Logger.info("App failed opening");
}
</script>

In the config.xml

<feature name="OpenExternalApp">
    <param name="android-package" value="com.Student.OpenExternalApp" />
</feature>

1 Answers1

0

Plenty of existing questions about this topic, some with example projects. Why not take a look.

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Using your example I am getting D/PluginManager(19326): exec() call to unknown plugin: OpenExternalAppPlugin – Zachary Loughridge May 05 '16 at 11:53
  • The error means your project is not correctly setup with the plugin. You can check the worklight documentation how to setup a project with a Cordova plugin. I believe you likely did not put it in the correct place. – Idan Adar May 05 '16 at 11:58
  • Got it thanks! There was issue with naming convention and that I didn't realize I had to add the java and config to both native, nativeResources folders. One issue though it that these updates are not getting direct push updates to the application. I had to export and install a new apk in order for them to take effect. Can you advise? – Zachary Loughridge May 05 '16 at 15:30
  • The plug-in is copied from the nativeResources folder into the native folder during build-time. – Idan Adar May 05 '16 at 15:30
  • One issue though it that these updates are not getting direct push updates to the application. I had to export and install a new apk in order for them to take effect. Can you advise? – Zachary Loughridge May 05 '16 at 15:32
  • These are native changes; Direct Update applies only the web resources (HTML, JS, CSS). – Idan Adar May 05 '16 at 15:45