facebookConnectPlugin is not defined (ngCordova, Ionic app) - angularjs

I'm trying to add native fb connect to my ionic app.
I'm using:
- Ionic
- ngCordova
- http://ngcordova.com/docs/plugins/facebook/
This is my code:
angular.module('starter.controllers', ['ngCordova'])
.config(function($cordovaFacebookProvider) {
var appID = 123456789;
var version = "v2.0"; // or leave blank and default is v2.0
$cordovaFacebookProvider.browserInit(appID, version);
})
Which leads to this error >
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
ReferenceError: facebookConnectPlugin is not defined
at browserInit (http://localhost:8100/lib/ngCordova/dist/ng-cordova.js:1576:7)
at http://localhost:8100/js/controllers.js:6:30
at Object.invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11994:17)
at runInvokeQueue (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11900:35)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11909:11
at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8147:20)
at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11890:5)
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:11907:40
at forEach (http://localhost:8100/lib/ionic/js/ionic.bundle.js:8147:20)
at loadModules (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11890:5)
Tried a couple of things but without any positive result:
- When I build it and run it on my device the app displays a blank screen
Tried the normal cordova js code:
Changed $cordovaFacebookProvider to $cordovaFacebook (based on this thread:
forum.ionicframework.com/t/unknown-provider-cordovaprovider/13305/3
And this is a another related thread, but doesn't help me thought..
forum.ionicframework.com/t/does-ng-crodova-has-facebook-login/9163
I already have a prototype working with the fb auth in the in-app-browser. But I really want to have a native fb connect functionality.

i found a way to resolve this issue.
Thanks to this thread : https://github.com/driftyco/ng-cordova/issues/446
and this tutorial : https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/browser/README.md
1st step : Don't forget the <div id="fb-root"></div> after ur body.
2nd step : I added facebookConnectPlugin to my bower dependencies
See my bower.json :
"dependencies": {
"angular-google-maps": "~2.0.13",
"google-map": "~0.4.1",
"facebook-connect-plugin": "https://cdn.rawgit.com/Wizcorp/phonegap-facebook-plugin/master/facebookConnectPlugin.js"
}
See my app.config + code to init:
app.config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider, $animateProvider, $httpProvider, $cordovaFacebookProvider) {
var appID = 597135743751760;
var version = "v2.0"; // or leave blank and default is v2.0
$cordovaFacebookProvider.browserInit(appID, version);
$cordovaFacebookProvider call facebookConnectPlugin()
3th step : After changing this dependencies, don't forget to call bower update from ur CLI.
4th step : Include the new facebookblablabla.js in your index.html.
it can be
<script src='bower_components/facebook-connect-plugin/index.js'></script>
for me it was
<script src='lib/facebook-connect-plugin/index.js'></script>
5th step : add in the Valid OAuth redirect URIs field at your Facebook App :
http://static.ak.facebook.com/connect/xd_arbiter/
Hope it works for you :) !

My answer is not providing a solution for your issue but an advice.
Why using facebook Cordova when you can use HelloJS?
faceBook Cordova is platform dependant, much slower as it runs cordova true node.js and not evolutive.
HelloJS permits to integer various Oauth2 authentication very easily including, facebook / google / twitter / instagram ...
Without to tell that the compilation for facebook cordova is very tricky with the facebook key app. On HelloJS, this is only a parameter that you can easily change.

I don't know if someone still stuck with this thing then please follow the method mentioned my #Alexy and then edit the 'lib/facebook-connect-plugin/index.js' file line from :
if(cordova.platformId === 'browser')
to
if(!window.cordova || (window.cordova && window.cordova.platformId === 'browser'))
Hope this Helps :)

Related

Failed to instantiate module ui-mask angulajs with rquirejs

I need to mask my input in my application. I was using ngMask in angularjs. But i found an issue in ngMask is that if we update the mid value the cursor move to end. I tried to resolve the issue but did not find anything. Even on github this issue has reported but still not resolved. Here is the link
ngMask Issue
Then i decided to use another mask library. I found ui-mask and trying to use in my application but i am getting error when i include in my project. My application is in angularjs and i am using requirejs as well to load the modules.
This is what i have done in main.js:
paths: {
...////
"angular-ui-mask": "../../lib/ui-mask/ui-mask.min",
},
'angular-ui-mask': {
deps: ['angular'],
exports: 'angular-ui-mask'
},
in app.js i have done:
var app = angular.module("app",
[
"ui.router",
"mobile-angular-ui",
"scrollable-table", //for alert triggering
"rzModule", //slider for SEMI diagram
"isteven-multi-select",
"ui.bootstrap",
"cgBusy", "dndLists", 'apm-kpi-widget',
'angular.filter',
"pascalprecht.translate",
"jQueryScrollbar",
"ui.checkbox",
"angular-ui-mask"
])
This is exact i was doing for ngMask. But in this case i am getting error
[$injector:modulerr] http://errors.angularjs.org/1.5.5/$injector/modulerr?
at angular.js:38
at angular.js:4587
at q (angular.js:322)
at g (angular.js:4548)
at bb (angular.js:4470)
at c (angular.js:1746)
at Object.yc [as bootstrap] (angular.js:1767)
at HTMLDocument.<anonymous> (angularAMD.js:449)
at i (jquery-1.12.3.min.js?v=1531811705531:2)
at Object.add [as done] (jquery-1.12.3.min.js?v=1531811705531:2)
What's the issue?

Drupal Wiris integration

I followed this tutorial to install the Wiris plugin on a new installation of Drupal.
Once the installation was complete and I clicked on the Wiris icon to begin adding a formula, the popup window does NOT load and I get the following error in the console area:
Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Invalid target origin '/DrupalQuiz/sites/all/libraries/ckeditor/plugins/ckeditor_wiris/' in a call to 'postMessage'.
at http://*.*.*.*/DrupalQuiz/sites/all/libraries/ckeditor/plugins/ckeditor_wiris/core/core.js:19:22
The code causing the problem is as follows:
e.source.postMessage(postVariable, _wrs_conf_path);
I'm at a loss how to deal with this issue.
I don't have a complete fix but I was able to get it working locally by replacing _wrs_conf_path with the base path of my dev box. _wrs_conf_path was evaluating to a relative path to the plugins folder.
if (typeof(e.source) != 'undefined') {
e.source.postMessage(postVariable, _wrs_conf_path);
}
with
if (typeof(e.source) != 'undefined') {
e.source.postMessage(postVariable, _wrs_currentPath);
}
in the /sites/all/libraries/ckeditor/plugins/ckeditor_wiris/core/core.js file.
Edit: I replaced _wrs_conf_path with one of their internal variables _wrs_currentPath and that seemed to fix the issue.

TypeError: Cannot read property 'local' of undefined at Object.schedule (ng-cordova.js:5042)

I have a problem scheduling local notifications with the ionic framework.
this is the angular module of my app.js
angular.module('starter', ['ionic','chart.js','ngCordova'])
with a controller
.controller("ExampleController", function($scope, $ionicPlatform,$interval,$cordovaLocalNotification)
i try to create a notification with this method
scheduleInstantNotification = function () {
$cordovaLocalNotification.schedule({
id: 1,
text: 'Value out of bound',
title: 'Anomaly'
}).then(function () {
alert("Instant Notification set");
});;
};
when running on an android device i get this error message:
TypeError: Cannot read property 'local' of undefined
at Object.schedule (ng-cordova.js:5042)
at scheduleInstantNotification (app.js:138)
at app.js:64
at ionic.bundle.js:56230
at Object.ready (ionic.bundle.js:2140)
at Object.ready (ionic.bundle.js:56223)
at app.js:62
at callback (ionic.bundle.js:25611)
at Scope.$eval (ionic.bundle.js:30395)
at Scope.$digest (ionic.bundle.js:30211)
I suspect that this error comes from the ngCordova library the error comes from this code part of the library
schedule: function (options, scope) {
var q = $q.defer();
scope = scope || null;
$window.cordova.plugins.notification.local.schedule(options, function (result) {
q.resolve(result);
}, scope);
return q.promise;
},
the $window.cordova.plugins.notification.local object is undefined.
Did I miss something in the controller?
EDIT
adding the required plugin with:
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
causes a compiler error when running
ionic build android
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find any matches for com.android.support:support-v4:+ as no versions of com.android.support:support-v4 are available.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
https://repo1.maven.org/maven2/com/android/support/support-v4/
https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml
https://jcenter.bintray.com/com/android/support/support-v4/
Required by:
:android:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
You need to add the plugin with :
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
as instructed on ngcordova documentation :
http://ngcordova.com/docs/plugins/localNotification/
Be sure also to call any method from the plugin after $ionicPlatform.ready.
EDIT
To your error when compiling with this plugin, please be sure to have Android Support Library installed with the Android SDK Manager.

yeoman generator-material-app: not working

I started estudr the yeoman and testing a generator equipment-app (https://github.com/michaelkrone/generator-material-app) I came across a problem. When performing APPLICATION, get umo following error in the browser console:
TypeError: cssClasses.split is not a function
at jqLiteAddClass (angular.js:2897)
at Function.$get.extend.addClass (angular.js:3538)
at angular-animate.js:119
at forEach (angular.js:336)
at $$addClass (angular-animate.js:118)
at options (angular-animate.js:132)
at close (angular-animate.js:2328)
at queueAnimation (angular-animate.js:2156)
at Object.$$AnimateQueueProvider.$get.push (angular-animate.js:2053)
at Object.$AnimateProvider.$get.leave (angular.js:5224)
I identified that the angle is coming a function in cssClasses parameter rather than a string as follows:
cssClasses = (arg1, arg2, arg3) {
2893
if (cssClasses && element.setAttribute) {
2894
var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
I have done: npm install, install bower and gulp build but none of that helped a lot.
Anyone know anything I can do to work around this?
It is actually quite simple. There is a problem with jqlite, then we can install the full jquery in front of angularjs.
As AngularJS documentation states, if jquery is loaded before AngularJS script, jquery will be used instead of jqlite.
Since the problem is in jqlite, so if we use jquery instead of jqlite, the problem goes away.
All you need to do is:
$ bower install --save jquery
and then add the following line before angular.js script loading:
<script src="./bower_components/jquery/dist/jquery.js"></script>
And this problem should goes away.

Application.js get cleaned up when building project with Visual Studio

I have download the sample https://github.com/tastejs/todomvc/tree/master/examples/typescript-angular and I try to get it working under a VS2013 Web Application empty template.
I add all the file of the sample, I launch the website by IIS, it works fine.
But when I build the project (without modifying anything) the only lines that remain are :
/// <reference path='_all.ts' />
/**
* The main TodoMVC app module.
*
* #type {angular.Module}
*/
var todos;
(function (todos) {
'use strict';
var todomvc = angular.module('todomvc', []).controller('todoCtrl', todos.TodoCtrl).directive('todoBlur', todos.todoBlur).directive('todoFocus', todos.todoFocus).service('todoStorage', todos.TodoStorage);
})(todos || (todos = {}));
When I try to run the website I have the following error :
http://localhost/WebAppTodoMvc/bower_components/angular/angular.js
0x800a139e - Erreur d’exécution JavaScript: [$injector:modulerr] Failed to instantiate module todomvc due to
Error: [ng:areq] Argument 'directiveFactory' is required
That code is meant to work with the --out compiler flag and you should use _all.js generated from all.ts https://github.com/tastejs/todomvc/blob/master/examples/typescript-angular/js/_all.ts
You can specify this as the reference file from your project properties.

Resources