0

I have a Cordova application that uses MobileFirst Platform version 8, Ionic version 1.3.1 and AngularJS version 1.5.3. When I run it and bootstrap Angular JS so that the app connects to the MobileFirst Platform first I get the following error:

Error in Success callbackId: WLAuthorizationManagerPlugin561212842 : Error: [$injector:modulerr] Failed to instantiate module ng due to:
TypeError: Cannot set property 'aHrefSanitizationWhitelist' of null
    at $$SanitizeUriProvider (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:30845:35)
    at new <anonymous> (file:///android_asset/www/plugins/cordova-plugin-mfp/worklight/worklight.js:1079:23)
    at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:18010:14)
    at provider (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17824:36)
    at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:13735:32
    at forEach (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:13705:20)
    at Object.provider (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17814:9)
    at ngModule (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:15863:16)
    at Object.invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17995:19)
    at runInvokeQueue (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17888:35)
http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=ng&p1=TypeError%3A%…2F%2Fandroid_asset%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A17888%3A35)

Can someone help me fix this?

I have found a similar question has been asked before, but that was for MobileFirst Platform version 7 and doesn't seem to be solved.

Thanks for the help!

Community
  • 1
  • 1
iqueqiorio
  • 1,149
  • 2
  • 35
  • 78

1 Answers1

2

A new version of cordova-plugin-mfp will be released in couple of days where the above issue will be addressed.

Meanwhile you can use the following workaround to resolve the issue.

  1. Replace the following code in worklight.js which you can find in the following path for different environments.

Android - Project/plugins/cordova-plugin-mfp/src/android/assets/www/worklight/worklight.js

iOS - Project/plugins/cordova-plugin-mfp/src/ios/www/worklight/worklight.js

Windows - Project/plugins/cordova-plugin-mfp/src/windows/www/worklight/worklight.js

function bind(context) {
if (arguments.length < 2 && WLJSX.Object.isUndefined(arguments[0])) {
return this;
}
var __method = this,
args = slice.call(arguments, 1);
return function() {
var a = merge(args, arguments);
return __method.apply(context, a);
};
}

should be replaced with

function bind(obj) {
var args = Array.prototype.slice.call(arguments, 1),
self = this,
Nop = function() {
},
bound = function() {
return self.apply(
this instanceof Nop ? this : (obj || {}), args.concat(
Array.prototype.slice.call(arguments)
)
);
};
Nop.prototype = this.prototype || {};
bound.prototype = new Nop();
return bound;
}
  1. Remove the platform and add the platform again.
Vittal Pai
  • 3,317
  • 25
  • 36
  • what do you mean "we will update MFP"? Also is this just a problem with android or if on iOS do I need to run `cordova platform update ios--save` – iqueqiorio Aug 11 '16 at 18:18
  • Also I tried this and when I change the function to what you said to change it to, then I run `cordova platform update android --save`, but the when I run the project with `cordova run` the file reverts back to the original function and I get the same error – iqueqiorio Aug 11 '16 at 18:29
  • Try with deleting and re adding the platform. – Vittal Pai Aug 11 '16 at 18:33
  • I did that (removed and re-added platform) and the file still reverted back to the old function? – iqueqiorio Aug 11 '16 at 18:35
  • How exactly you removing and re-adding the platform ? I deleted the platform folder manually and re-added the platform using command `cordova platform add ios`. It worked for me. – Vittal Pai Aug 11 '16 at 18:45
  • got it to work now, would you be able to let me know when the new cordova-plugin-mfp update comes out or will it just be doing what i fixed? or is there other stuff that it will have also? – iqueqiorio Aug 11 '16 at 19:00
  • This is just a workaround. New version of cordova-plugin-mfp will be released in couple of days. – Vittal Pai Aug 11 '16 at 19:21
  • @iqueqiorio If this has solved your problem please accept this as the answer. – S.A.Norton Stanley Aug 12 '16 at 05:13
  • Great news @VittalPai - please could you add the release number here when it's available? Thanks! – Nick Maynard Aug 12 '16 at 20:49
  • @VittalPai I updated to the new version today and am still getting the same error – iqueqiorio Aug 18 '16 at 18:06
  • @VittalPai the new version still gives the same error do you see the same behaviour? – iqueqiorio Aug 24 '16 at 15:49
  • @iqueqiorio Yes the fix is not present in the latest one. In upcoming release of cordova mfp plugin, the issue will be fixed. – Vittal Pai Aug 31 '16 at 17:56