1

I am working on a project which require IBM MobileFirst as an integral part of the application so, trying to invoke the function Wl.send(), to make a connection to the database but seems in the new cordova-plugin-mfp it has been deprecated, please suggest me the alternate of this function or the new invoking procedure of this function.

here are my ionic info and plugin details with MobileFirst Veriosn 8.0

@ionic/cli-utils  : 1.10.2
ionic (Ionic CLI) : 3.10.3

local packages:

@ionic/app-scripts : 2.1.4
Ionic Framework    : ionic-angular 3.6.1

System:

Node : v6.10.3
npm  : 3.10.10
OS   : Windows 8.1
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-globalization 1.0.7 "Globalization"
cordova-plugin-mfp 8.0.2017090705 "IBM MobileFirst Platform Foundation"
cordova-plugin-mfp-push 8.0.2017082110 "IBM MobileFirst Platform Foundation - Push Notifications"
cordova-plugin-okhttp 2.0.0 "OkHttp"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Below is the code we are using to connect to data base

   var resourceRequest = new WLResourceRequest("adapters/SQLAdapter/unprotected", WLResourceRequest.GET);

   console.log(resourceRequest);
   resourceRequest.send().then((response) => {
     console.log("Here I am in...");
       console.log(response.responseText);
     },(error) => { 
       console.log("error in function:-");
       console.log(error);
   });

Error in the code is :-

Error:--- ERROR TypeError: Cannot read property 'getItem' of undefined at __WLDAO.getItem (ibmmfpf-preview.js:8285) at getItemFromMap () – 

2 Answers2

0

new invoking procedure in MobileFirst 8.0

To invoke the procedure you have to use WLResourceRequest and resourceRequest.send().

For example:

var resourceRequest = new WLResourceRequest(
    "/adapters/JavaAdapter/users",
    WLResourceRequest.GET
);
var formParams = {"param1": "value1", "param2": "value2"};
resourceRequest.sendFormParameters(formParams);

resourceRequest.send().then(
    onSuccess,
    onFailure
)

I suggest that you will take a tour of the MobileFirst Foundation Development in Cordova or ionic based applications . See here:

Integrating MobileFirst Foundation 8.0 in Ionic-based apps: https://mobilefirstplatform.ibmcloud.com/blog/2016/07/19/integrating-mobilefirst-foundation-8-in-ionic-based-apps/

Adding the MobileFirst Foundation SDK to Cordova Applications: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/sdk/cordova/

Resource request from JavaScript (Cordova, Web) applications: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/resource-request/javascript/

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
  • Thank you for your reply, I know this method but it is not working, it was working just before the latest update of cordova-mfp-plugin. but since I updated my plugin We are not able to call the method Error:--- ERROR TypeError: Cannot read property 'getItem' of undefined at __WLDAO.getItem (ibmmfpf-preview.js:8285) at getItemFromMap () – Manish Prajapati Sep 19 '17 at 06:46
  • can you post your code sample what you are using to invoke procedure ? update code in your question itself.. – Gaurab Kumar Sep 19 '17 at 06:47
  • Are you noticing this error when running preview mode? If so, test in a simulator or actual device and check if it is working fine? – Vivin K Sep 19 '17 at 07:05
  • @VivinK Yah this error is while previewing the application but I tried it on device as well so same error was there during debugging through device. – Manish Prajapati Sep 19 '17 at 07:13
  • @ManishPrajapati can you update your error exactly what you are getting ? – Gaurab Kumar Sep 19 '17 at 07:15
  • @VivinK ERROR UPDATED – Manish Prajapati Sep 19 '17 at 07:24
  • Does the flow enter the success callback? If so, print the entire contents of the response and see if you are missing something. – Vivin K Sep 19 '17 at 09:49
0

try to downgrade the cordova-plugin-mfp and then try to invoke it, seems they have not released the document. I am working with cordova-plugin-mfp

8.0.2017072706

try with it

sparrowTrajon
  • 182
  • 1
  • 10