Migration guide from FreshPlanet ANE - nodrock/ANE-Facebook GitHub Wiki

Migration guide from FreshPlanet

Logging

FreshPlanet ANE:

var fb:Facebook = Facebook.getInstance();
fb.logEnabled = true|false;

This ANE:

Facebook.logEnabled = true|false; // enable or disable log in AS3
Facebook.nativeLogEnabled = true|false; // enable or disable logging to logCat on Android and to iOS developer console on iOS

Login

FreshPlanet ANE:

var fb:Facebook = Facebook.getInstance();
fb.init(FACEBOOK_APP_ID, false);
if(!fb.isSessionOpen){ // check for session
   fb.openSessionWithReadPermissions(FACEBOOK_READ_PERMISSIONS, handleOpenSession); // open session
} 
...
fb.reauthorizeSessionWithPublishPermissions(FACEBOOK_POST_PERMISSIONS, callback); 
...
fb.closeSessionAndClearTokenInformation();

This ANE:

var fb:Facebook = Facebook.getInstance();
/*
FACEBOOK_APP_ID should be set here only if there is not this meta-data in Android application descriptor:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb{YOUR_FB_APPLICATION_ID}"/>
*/
fb.init(FACEBOOK_APP_ID, onInitialized);

...

private function onInitialized():void
{ 
  if(fb.accessToken == null || fb.accessToken.permissions.indexOf(FACEBOOK_READ_PERMISSIONS) == -1){ // check for session and if there is one check if there is permission we need
     fb.logInWithReadPermissions([FACEBOOK_READ_PERMISSIONS], handleOpenSession); // open session
  } 
  ...
  if(fb.accessToken.indexOf(FACEBOOK_POST_PERMISSIONS) == -1){ // ask for post permissions only if you don't have them already
     fb.logInWithPublishPermissions([FACEBOOK_POST_PERMISSIONS], callback);
  }
}
...
fb.logOut();

Other changes

  • You don't need to call fb.activateApp(). It is called automatically for you.
  • You can get string representation of accessToken with fb.accessToken.tokenString
  • Expiration timestamp is in fb.accessToken.expirationDate
  • legacyMode is not supported
  • There is no webDialog or dialog
  • OpenGraph is not implemented yet