mkloubert / nativescript-social-login

NativeScript plugin for social (token based) log-ins.
MIT License
42 stars 44 forks source link

I am getting this error " undefined variable FBSDKLoginManager" #67

Open lettertoamit opened 5 years ago

lettertoamit commented 5 years ago

Can't find variable: FBSDKApplicationDelegate,

app.js

const application = require("tns-core-modules/application");

if(application.ios){ `

var AppDelegate = UIResponder.extend({ applicationDidFinishLaunchingWithOptions :function (application, launchOptions) { var gglDelegate = false; try { var errorRef = new interop.Reference(); GGLContext.sharedInstance().configureWithError(errorRef); var signIn = GIDSignIn.sharedInstance(); gglDelegate = true; } catch (error) { console.log(error); } var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions); // facebook login delegate return gglDelegate || fcbDelegate; }, applicationOpenURLSourceApplicationAnnotation : function (application, url, sourceApplication, annotation) { var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation); // facebook login delegate var gglDelegate = GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url, sourceApplication, annotation); // google login delegate return fcbDelegate || gglDelegate; }

},{ name: "AppDelegate", protocols:[UIApplicationDelegate]

}); application.ios.delegate = AppDelegate; } application.run({ moduleName: "app-root" });

The js code given in https://github.com/mkloubert/nativescript-social-login#javascript . not working , i am working on nativescript( javascript ) without any framework like TS , angular or view.

rhhansen commented 5 years ago

Here is my version:

const application   = require("tns-core-modules/application");
const localize      = require("nativescript-localize");
var SocialLogin     = require("nativescript-social-login");

application.setResources({ L: localize });

application.on(application.launchEvent, function (args) {

});
if (application.ios) {
    var MyDelegate = (function (_super) {
        __extends(MyDelegate, _super);
        function MyDelegate() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        MyDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {
            var gglDelegate = false;
            try {
                var errorRef = new interop.Reference();
                GGLContext.sharedInstance().configureWithError(errorRef);
                var signIn = GIDSignIn.sharedInstance();
                gglDelegate = true;
            }
            catch (error) {
                console.log(error);
            }
            var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions); // facebook login delegate
            return gglDelegate || fcbDelegate;
        };
        MyDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = function (application, url, sourceApplication, annotation) {
            var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation); // facebook login delegate
            var gglDelegate = GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url, sourceApplication, annotation); // google login delegate
            return fcbDelegate || gglDelegate;
        };
        MyDelegate.ObjCProtocols = [UIApplicationDelegate];
        return MyDelegate;
    }(UIResponder));
    application.ios.delegate = MyDelegate;
}
if (application.android) {
    application.android.on(application.AndroidApplication.activityResumedEvent, () => {
        let result = SocialLogin.init();
    });
}
application.run({ moduleName: "app-root/app-root" });
lettertoamit commented 5 years ago

Here is my version:

const application   = require("tns-core-modules/application");
const localize      = require("nativescript-localize");
var SocialLogin     = require("nativescript-social-login");

application.setResources({ L: localize });

application.on(application.launchEvent, function (args) {

});
if (application.ios) {
    var MyDelegate = (function (_super) {
        __extends(MyDelegate, _super);
        function MyDelegate() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        MyDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (application, launchOptions) {
            var gglDelegate = false;
            try {
                var errorRef = new interop.Reference();
                GGLContext.sharedInstance().configureWithError(errorRef);
                var signIn = GIDSignIn.sharedInstance();
                gglDelegate = true;
            }
            catch (error) {
                console.log(error);
            }
            var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationDidFinishLaunchingWithOptions(application, launchOptions); // facebook login delegate
            return gglDelegate || fcbDelegate;
        };
        MyDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = function (application, url, sourceApplication, annotation) {
            var fcbDelegate = FBSDKApplicationDelegate.sharedInstance().applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation); // facebook login delegate
            var gglDelegate = GIDSignIn.sharedInstance().handleURLSourceApplicationAnnotation(url, sourceApplication, annotation); // google login delegate
            return fcbDelegate || gglDelegate;
        };
        MyDelegate.ObjCProtocols = [UIApplicationDelegate];
        return MyDelegate;
    }(UIResponder));
    application.ios.delegate = MyDelegate;
}
if (application.android) {
    application.android.on(application.AndroidApplication.activityResumedEvent, () => {
        let result = SocialLogin.init();
    });
}
application.run({ moduleName: "app-root/app-root" });

really thank you for your reply , I will try it on . But I used nativescript-oauth2 plugin for now .

karthikbalu commented 4 years ago

I had the same issue and resolved it

add below lines before if (application.ios) {

` declare class UIResponder {}; declare class UIApplicationDelegate{}; declare class FBSDKApplicationDelegate { static sharedInstance():any; };

declare class GGLContext { static sharedInstance():any; };

declare class GIDSignIn { static sharedInstance():any; };

declare class FBSDKAppEvents{ static activateApp(); }; declare class UIApplication {}; declare class NSDictionary {};`