             NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, onActivate);
             NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivate);
 
-            _instance = this;
         }
         else {
             throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");


    private static function isIOS():Boolean
    {
        return Capabilities.version.indexOf("IOS") != -1;
    }

    private static function isAndroid():Boolean
    {
        return Capabilities.version.indexOf("AND") != -1;
    }

    public function Facebook()
    {
        if(!isSupported){
            throw new Error("This extension is supported only on iOS and Android!");
        }
        if (!_instance) {
            _context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
            if (!_context) {
                log("ERROR - Extension context is null. Please check if extension.xml is setup correctly.");


    public static function getInstance():Facebook
    {
        return _instance ? _instance : new Facebook();
    }

