-1

I am working on ionic with mobilefirst project. While i am trying to integrate ionic App with mobile first, the mobilefirst server is not connecting with my App, in the server console i am not getting any information regarding to my App.

Configuration:

  • mobilefirst: 8.0.0
  • cordova: 6.1.1
  • android: 5.1.1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Priya
  • 126
  • 7

1 Answers1

1

To first step in order to have the MobileFirst Server recognize your application is to register the application. You can do this in two ways:

  1. Using the MobileFirst CLI

    • Make sure you have the CLI installed
    • navigate to the root folder of the application project
    • Run the command: mfpdev app register
  2. Directly from the MobileFirst Console. This step will require you to manually enter the details of your application

    • Load the console, typically localhost:9080/mfpconsole (if running the server locally)
    • Next to "Applications" in the sidebar navigation click on "New"
    • Provide the app details:
    • Name
    • Platform
    • bundle ID and version (you can find these in the config.xml file of your application project

The next step is to actually have the application send a request to the server to see if the connection succeeded...

Add the SDK by running the command: cordova plugin add cordova-plugin-mfp

Open the index.js file of your application and add the following code (just an example):

function wlCommonInit() {
    WLAuthorizationManager.obtainAccessToken().then(
        function () {       
            alert ("successfully obtained a token from the server");
        },
        function(response) {
                    alert("Unable to obtain a token from the server: " + JSON.stringify(response));
        }
    );
}

Take a look at this Ionic example: https://github.com/csantanapr/mfp8-ionic-demo/blob/master/www/js/app.js

Once the custom "MFP init" has been fired, you can then use the above WLAuthorizationManager API.

If it fails, then you did not properly register your application.

  • Make sure the version is correct
  • Make sure the bundle name is correct

Please read through the tutorials: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/all-tutorials/

You can also find Ioic app examples with MFP, here: https://mobilefirstplatform.ibmcloud.com/labs/developers/8.0/intro/

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Thank u Idan. I have done all the steps.Then in ionic i have added & tested with your given code in app.js file. I getting some error in console as, wlclient init started worklight.js:5090 before: initOptions.onSuccess worklight.js:5090 Connected worklight.js:5090 after: initOptions.onSuccess worklight.js:5090 wlclient init success worklight.js:5090 getCachedAccessToken for scope failed: undefined – Priya May 12 '16 at 04:55
  • You must execute MFP APIs inside `wlCommonInit() { ... }` – Idan Adar May 12 '16 at 04:58
  • This is the factory which we are using... window.MFPClientDefer = angular.injector(['ng']).get('$q').defer();; window.wlCommonInit = window.MFPClientDefer.resolve; window.MFPClientDefer.promise.then(function wlCommonInit(){ WLAuthorizationManager.obtainAccessToken().then( function () { alert ("successfully obtained a token from the server"); }, function(response) { alert("Unable to obtain a token from the server: " + JSON.stringify(response)); } ); mfpMagicPreviewSetup(); }); – Priya May 12 '16 at 05:02
  • Try again, with only wlCommonInit, in index.js. If it works, then open a new question and direct it at the Ionic community and not MFP. – Idan Adar May 12 '16 at 05:07
  • app.js file is the base for ionic app. There is no index.js file. we are just trying to implement mfp features in ionic app with angularjs.That i have already mentioned in my question. – Priya May 12 '16 at 05:12
  • Follow the lab examples: https://mobilefirstplatform.ibmcloud.com/labs/developers/8.0/intro/ – Idan Adar May 12 '16 at 05:13
  • As well as this video: https://mobilefirstplatform.ibmcloud.com/blog/2016/04/11/getting-started-with-ionic-and-ibm-mobilefirst-platform-foundation-8-0/ – Idan Adar May 12 '16 at 05:35
  • Now i can able to see device details in mfpserver by running my app using emulator (Geny Motion). The command what i was used is "ionic run android --livereload" . But i not able to see those device details while running my app with the real device. I have attached my sample project in the following github path, https://github.com/Smohanapriya/mobilefirst – Priya May 12 '16 at 09:15
  • You already asked that question, here: https://stackoverflow.com/questions/37139441/not-able-to-get-the-device-information-in-ibm-mobile-first-console-with-ionic – Idan Adar May 12 '16 at 15:38
  • Working Sample, https://github.com/Smohanapriya/ionic-with-mobilefirst-8.0.0-beta-Sample – Priya May 13 '16 at 06:12
  • suddently, today i am not able to connect with mfpserver using your same above function.can you provide me your solution? – Priya Jul 07 '16 at 09:06
  • You have likely updated either your client side SDK but did not update the server, or updated your server but did not update your SDK... – Idan Adar Jul 07 '16 at 09:09
  • I have tried to install mfpdev cli using npm command & also developer kit. but i am not able to download the latest developer kit from the https://mobilefirstplatform.ibmcloud.com/downloads/ – Priya Jul 07 '16 at 09:14
  • Idan, I have updated client SDK. Can you provide me the link to update mfp server? – Priya Jul 07 '16 at 11:08
  • The download is not available. For now you can use the Mobile Foundation Bluemix service. – Idan Adar Jul 07 '16 at 11:22