Skip to content

Commit

Permalink
Merge branch 'master' into fb-ios-sdk-7.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysingh-axway authored Jan 23, 2021
2 parents 1d801fa + e9afd31 commit add3add
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 11.0.1
version: 11.0.2
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: facebook
Expand Down
52 changes: 34 additions & 18 deletions android/src/facebook/ActivityWorkerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.*;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
Expand All @@ -26,7 +27,7 @@ public class ActivityWorkerProxy extends KrollProxy implements OnActivityResultE
{
private static final String TAG = "ActivityWorkerProxy";

private AccessTokenTracker accessTokenTracker;
private AccessTokenTracker accessTokenTracker = null;

public ActivityWorkerProxy()
{
Expand All @@ -46,40 +47,55 @@ public void handleCreationDict(KrollDict options)

// Obtain activity result.
baseActivity.addOnActivityResultListener(this);
}

// Create access token tracker.
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken)
{
if (currentAccessToken == null) {

// Create access token tracker.
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken)
{
if (currentAccessToken == null) {

// User logged out.
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_LOGOUT, null);
} else {

// AccessToken updated.
if (TiFacebookModule.getFacebookModule().isAccessTokenRefreshCalled()) {
TiFacebookModule.getFacebookModule().setAccessTokenRefreshCalled(false);
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_TOKEN_UPDATED, null);
}
// User logged out.
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_LOGOUT, null);
} else {

// AccessToken updated.
if (TiFacebookModule.getFacebookModule().isAccessTokenRefreshCalled()) {
TiFacebookModule.getFacebookModule().setAccessTokenRefreshCalled(false);
TiFacebookModule.getFacebookModule().fireEvent(TiFacebookModule.EVENT_TOKEN_UPDATED, null);
}
}
};
}
};
}

@Override
public void onCreate(Activity activity, Bundle savedInstanceState)
{
Log.d(TAG, "onCreate");

if (activity instanceof TiBaseActivity) {
final TiBaseActivity baseActivity = (TiBaseActivity) activity;

// Obtain activity result.
baseActivity.addOnActivityResultListener(this);
}
}

@Override
public void onDestroy(Activity activity)
{
Log.d(TAG, "onDestroy");

accessTokenTracker.stopTracking();
}

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data)
{
Log.d(TAG, "onActivityResult");

TiFacebookModule.getFacebookModule().getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
}

0 comments on commit add3add

Please sign in to comment.