Skip to content
This repository was archived by the owner on Apr 2, 2021. It is now read-only.

Update fbsdk to v5 on Android #546

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ DerivedData
*.xcuserstate
project.xcworkspace

# Cocoapods
# Android/IntelliJ
#
Pods/
build/
.idea
.gradle
local.properties
*.iml

# Editor
# Cocoapods
#
.idea/
Pods/

# node.js
#
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28
def DEFAULT_FACEBOOK_SDK_VERSION = "4.38.1"
def DEFAULT_FACEBOOK_SDK_VERSION = "[5.0,5.1["

def FACEBOOK_SDK_VERSION = rootProject.hasProperty('facebookSdkVersion') ? rootProject.facebookSdkVersion : DEFAULT_FACEBOOK_SDK_VERSION

Expand All @@ -25,8 +25,8 @@ android {
}

dependencies {
implementation "androidx.appcompat:appcompat:1.0.2"
api 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
implementation "androidx.appcompat:appcompat:1.0.+"
api 'com.facebook.react:react-native:+'
api "com.facebook.android:facebook-android-sdk:${FACEBOOK_SDK_VERSION}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void setConfig(GraphRequest graphRequest, ReadableMap configMap) {
null,
null,
null,
null,
null));
} else {
graphRequest.setAccessToken(AccessToken.getCurrentAccessToken());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public List<NativeModule> createNativeModules(
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Arrays.<ViewManager>asList(
new FBLikeViewManager(),
new FBLoginButtonManager(reactContext, mCallbackManager),
new FBSendButtonManager(),
new FBShareButtonManager()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
import java.util.List;
import java.util.Set;

import androidx.annotation.Nullable;


/**
* This class is solely for the use of other packages within the React Native Facebook SDK for Android.
* Use of any of the classes in this package is unsupported, and they may be modified or removed
Expand All @@ -61,16 +64,18 @@ public static AccessToken buildAccessToken(ReadableMap accessTokenMap) {
.valueOf(accessTokenMap.getString("accessTokenSource"));
Date expirationTime = new Date((long) accessTokenMap.getDouble("expirationTime"));
Date lastRefreshTime = new Date((long) accessTokenMap.getDouble("lastRefreshTime"));
Date dataAccessExpirationTime = new Date((long) accessTokenMap.getDouble("dataAccessExpirationTime"));
return new AccessToken(
accessTokenMap.getString("accessToken"),
accessTokenMap.getString("applicationID"),
accessTokenMap.getString("userID"),
reactArrayToStringList(accessTokenMap.getArray("permissions")),
reactArrayToStringList(accessTokenMap.getArray("declinedPermissions")),
reactArrayToStringList(accessTokenMap.getArray("expiredPermissions")),
accessTokenSource,
expirationTime,
lastRefreshTime,
null
dataAccessExpirationTime
);
}

Expand All @@ -85,9 +90,13 @@ public static WritableMap accessTokenToReactMap(AccessToken accessToken) {
map.putArray(
"declinedPermissions",
Arguments.fromJavaArgs(setToStringArray(accessToken.getDeclinedPermissions())));
map.putArray(
"expiredPermissions",
Arguments.fromJavaArgs(setToStringArray(accessToken.getExpiredPermissions())));
map.putString("accessTokenSource", accessToken.getSource().name());
map.putDouble("expirationTime", (double) accessToken.getExpires().getTime());
map.putDouble("lastRefreshTime", (double) accessToken.getLastRefresh().getTime());
map.putDouble("dataAccessExpirationTime", (double) accessToken.getDataAccessExpirationTime().getTime());
return map;
}

Expand Down Expand Up @@ -294,7 +303,10 @@ public static String getValueOrNull(ReadableMap map, String key) {
return null;
}

public static List<String> reactArrayToStringList(ReadableArray array) {
public static @Nullable List<String> reactArrayToStringList(@Nullable ReadableArray array) {
if (array == null) {
return null;
}
List<String> list = new ArrayList<>(array.size());
for (int i = 0; i < array.size(); i++) {
list.add(array.getString(i));
Expand Down