Created
January 13, 2012 17:54
-
-
Save weizhu/1607776 to your computer and use it in GitHub Desktop.
Sample implementation for a PhoneGap FB Plugin that hook up necessary events from regular Facebook JS SDK so it override behavior for Auth and UI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FB.Event.subscribe('FB.init.start', | |
function(options) { | |
if (options.nativeInterface) { | |
FB._nativeInterface = options.nativeInterface; | |
FB._nativeInterface.init(FB._apiKey); | |
} | |
}); | |
FB.Event.subscribe('FB.auth.staticAuthCheck.start', | |
function(eventProps) { | |
// cancel default static auth check | |
eventProps.returnValue = false; | |
}); | |
FB.Event.subscribe('FB.ui.start', | |
function(eventProps, params, cb) { | |
if (!FB._nativeInterface) { | |
return; | |
} | |
switch (params.method) { | |
case 'permissions.request': | |
FB._nativeInterface.login(cb, params); | |
break; | |
case 'permissions.oauth': | |
FB._nativeInterface.login(cb, params); | |
break; | |
case 'auth.logout': | |
FB._nativeInterface.logout(cb); | |
break; | |
case 'auth.status': | |
FB._nativeInterface.getLoginStatus(cb); | |
break; | |
} | |
// Stop default handling | |
eventProps.returnValue = false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment