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:
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
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/