Troubleshooting

App crashes due to not waiting for AppConnect ready event

Problem

Your app crashes due to the following uncaught exception:

Function <function name> called before AppConnect is ready.

For example:

Function authState() called before AppConnect is ready.

The AppConnect library throws this exception if the app calls any of the following AppConnect Cordova Plugin methods before the AppConnect library is ready:

AppConnectCordova.managedPolicy()
AppConnectCordova.authState()
AppConnectCordova.authMessage()
AppConnectCordova.pasteboardPolicy()
AppConnectCordova.openInPolicy()
AppConnectCordova.openInWhitelist()
AppConnectCordova.printPolicy()
AppConnectCordova.config()

Solution

Refactor your code to make sure you check AppConnectCordova.isReady() before calling the listed methods. If AppConnectCordova.isReady() returns true, you can access the methods. If AppConnectCordova.isReady() returns false, wait for the AppConnect Cordova Plugin to generate the 'appconnect.isReady' event before calling the methods.

See AppConnect ready API details .