Sietse
Sietse

Reputation: 693

Building native application with MobileFirst

We are using MobileFirst 6.3 and we are almost finished, but building the native iOS application by adding the environment isn't that easy for us it seems. After creating the environment we tried to run the code, but we are left with a blank screen, which is scrollable, and an error:

Error in success callback: DeviceAuth1101721282 = TypeError: undefined is not an object (evaluating 'window.cordova.plugins.Keyboard')

It appears the Keyboard plugin is not available and the rest of the application won't load any further. Things I tried is adding the plugin found on Github (https://github.com/apache/cordova-plugins/tree/master/keyboard) to the iphone/native/CordovaLib/plugin directory and adding the following code to the iphone/native/config.xml file:

<feature name="Keyboard">
  <param name="ios-package" value="CDVKeyboard" />
</feature>

This doesn’t fix the problem. In the documentation how to add native functionality to the application (https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/adding-native-functionality/ios-adding-native-functionality-hybrid-application-apache-cordova-plugin/), the next step was to create a function, but I don’t have a function to call at the plugin so I created a temporary function according to the tutorial which only outputs to the console with NSLog. In the log I get the message following by the same error as before.

Is there anything I missed?

Upvotes: 0

Views: 156

Answers (1)

Sietse
Sietse

Reputation: 693

In one of the tutorials to build MobileFirst applications in combination with Ionic Framework, there was an if-statement which gave the error. The if-statement was:

if (window.cordova && window.cordova.plugins.keyboard) { ... }

While the fix was:

if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) { ... }

Now we have found the fix after 2 days, it seems quite obvious, but this line was somewhat hidden in the project and searching for keyboard gave lots of results.

Upvotes: 1

Related Questions