Skip to content

Commit

Permalink
Merge pull request #89 from hansemannn/update-facebook-sdk-4_29_0
Browse files Browse the repository at this point in the history
[MOD-2390] Update native Facebook SDK's (iOS/Android) to 4.29.0, deprecate APIs
  • Loading branch information
hansemannn authored Jan 24, 2018
2 parents fec1b0c + 87a53d0 commit 377c135
Show file tree
Hide file tree
Showing 48 changed files with 507 additions and 155 deletions.
Binary file removed android/lib/AudienceNetwork.aar
Binary file not shown.
Binary file added android/lib/bolts-applinks-1.3.0.aar
Binary file not shown.
Binary file added android/lib/bolts-tasks-1.3.0.jar
Binary file not shown.
Binary file removed android/lib/facebook-android-sdk-4.25.0.aar
Binary file not shown.
Binary file added android/lib/facebook-applinks.aar
Binary file not shown.
Binary file added android/lib/facebook-common.aar
Binary file not shown.
Binary file added android/lib/facebook-core.aar
Binary file not shown.
Binary file added android/lib/facebook-login.aar
Binary file not shown.
Binary file added android/lib/facebook-messenger.aar
Binary file not shown.
Binary file added android/lib/facebook-places.aar
Binary file not shown.
Binary file added android/lib/facebook-share.aar
Binary file not shown.
Binary file added android/lib/facebook.aar
Binary file not shown.
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: 7.0.0
version: 7.1.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: facebook
Expand Down
3 changes: 2 additions & 1 deletion android/src/facebook/LikeButtonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public LikeButtonProxy() {
defaultValues.put("likeViewStyle", "standard");
defaultValues.put("auxiliaryViewPosition", "bottom");
defaultValues.put("horizontalAlignment", "center");
Log.d(TAG, "[VIEWPROXY LIFECYCLE EVENT] init");
Log.d(TAG, "[VIEWPROXY LIFECYCLE EVENT] init");
Log.w(TAG, "The LikeButton API has been deprecated by the Facebook SDK 4.29.0 and will be removed in the future");
}

@Override
Expand Down
224 changes: 106 additions & 118 deletions android/src/facebook/TiFacebookModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Please see the LICENSE included with this distribution for details.
*
* Appcelerator Titanium Mobile
* Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2015-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
Expand Down Expand Up @@ -86,41 +86,40 @@ public class TiFacebookModule extends KrollModule implements OnActivityResultEve
public static final String EVENT_INVITE_COMPLETE = "inviteCompleted";
public static final String EVENT_REQUEST_DIALOG_COMPLETE = "requestDialogCompleted";

@Kroll.constant public static final int AUDIENCE_NONE = 0;
@Kroll.constant public static final int AUDIENCE_ONLY_ME = 1;
@Kroll.constant public static final int AUDIENCE_FRIENDS = 2;
@Kroll.constant public static final int AUDIENCE_EVERYONE = 3;
@Kroll.constant public static final int AUDIENCE_NONE = 0;
@Kroll.constant public static final int AUDIENCE_ONLY_ME = 1;
@Kroll.constant public static final int AUDIENCE_FRIENDS = 2;
@Kroll.constant public static final int AUDIENCE_EVERYONE = 3;

@Kroll.constant public static final int ACTION_TYPE_NONE = 0;
@Kroll.constant public static final int ACTION_TYPE_SEND = 1;
@Kroll.constant public static final int ACTION_TYPE_ASK_FOR = 2;
@Kroll.constant public static final int ACTION_TYPE_TURN = 3;
@Kroll.constant public static final int ACTION_TYPE_NONE = 0;
@Kroll.constant public static final int ACTION_TYPE_SEND = 1;
@Kroll.constant public static final int ACTION_TYPE_ASK_FOR = 2;
@Kroll.constant public static final int ACTION_TYPE_TURN = 3;

@Kroll.constant public static final int FILTER_NONE = 0;
@Kroll.constant public static final int FILTER_APP_USERS = 1;
@Kroll.constant public static final int FILTER_APP_NON_USERS = 2;
@Kroll.constant public static final int FILTER_NONE = 0;
@Kroll.constant public static final int FILTER_APP_USERS = 1;
@Kroll.constant public static final int FILTER_APP_NON_USERS = 2;

@Kroll.constant public static final String LOGIN_BEHAVIOR_BROWSER = "WEB_ONLY";
@Kroll.constant public static final String LOGIN_BEHAVIOR_NATIVE = "NATIVE_ONLY";
@Kroll.constant public static final String LOGIN_BEHAVIOR_NATIVE_WITH_FALLBACK = "NATIVE_WITH_FALLBACK";
@Kroll.constant public static final String LOGIN_BEHAVIOR_DEVICE_AUTH = "DEVICE_AUTH";
@Kroll.constant public static final String LOGIN_BEHAVIOR_BROWSER = "WEB_ONLY";
@Kroll.constant public static final String LOGIN_BEHAVIOR_NATIVE = "NATIVE_ONLY";
@Kroll.constant public static final String LOGIN_BEHAVIOR_NATIVE_WITH_FALLBACK = "NATIVE_WITH_FALLBACK";
@Kroll.constant public static final String LOGIN_BEHAVIOR_DEVICE_AUTH = "DEVICE_AUTH";

@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_AUTOMATIC = 0;
@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_FORCE_DISPLAY = 1;
@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_DISABLE = 2;
@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_AUTOMATIC = 0;
@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_FORCE_DISPLAY = 1;
@Kroll.constant public static final int LOGIN_BUTTON_TOOLTIP_BEHAVIOR_DISABLE = 2;

@Kroll.constant public static final String LOGIN_BUTTON_TOOLTIP_STYLE_NEUTRAL_GRAY = "NEUTRAL_GRAY";
@Kroll.constant public static final String LOGIN_BUTTON_TOOLTIP_STYLE_FRIENDLY_BLUE = "FRIENDLY_BLUE";

@Kroll.constant public static final int SHARE_DIALOG_MODE_AUTOMATIC = 0;
@Kroll.constant public static final int SHARE_DIALOG_MODE_NATIVE = 1;
@Kroll.constant public static final int SHARE_DIALOG_MODE_WEB = 2;
@Kroll.constant public static final int SHARE_DIALOG_MODE_FEED_WEB = 6; // For iOS-parity
@Kroll.constant public static final String LOGIN_BUTTON_TOOLTIP_STYLE_NEUTRAL_GRAY = "NEUTRAL_GRAY";
@Kroll.constant public static final String LOGIN_BUTTON_TOOLTIP_STYLE_FRIENDLY_BLUE = "FRIENDLY_BLUE";

@Kroll.constant public static final int SHARE_DIALOG_MODE_AUTOMATIC = 0;
@Kroll.constant public static final int SHARE_DIALOG_MODE_NATIVE = 1;
@Kroll.constant public static final int SHARE_DIALOG_MODE_WEB = 2;
@Kroll.constant public static final int SHARE_DIALOG_MODE_FEED_WEB = 6; // For iOS-parity

private static TiFacebookModule module;
private static String[] permissions = new String[]{};
private String loginBehavior;
private String loginBehavior;

private KrollFunction permissionCallback = null;

Expand All @@ -144,19 +143,19 @@ public static TiFacebookModule getFacebookModule() {
return module;
}

@Override
public void onResume(Activity activity) {
super.onResume(activity);
Log.d(TAG, "Calling activateApp");
AppEventsLogger.activateApp(activity);
}
@Override
public void onResume(Activity activity) {
super.onResume(activity);
Log.d(TAG, "Calling activateApp");
AppEventsLogger.activateApp(activity);
}

@Override
public void onPause(Activity activity) {
super.onPause(activity);
Log.d(TAG, "Calling deactivateApp");
AppEventsLogger.deactivateApp(activity);
}
@Override
public void onPause(Activity activity) {
super.onPause(activity);
Log.d(TAG, "Calling deactivateApp");
AppEventsLogger.deactivateApp(activity);
}

public CallbackManager getCallbackManager() {
return callbackManager;
Expand Down Expand Up @@ -243,7 +242,7 @@ public boolean getCanPresentOpenGraphActionDialog()
}

@Kroll.method
public void requestWithGraphPath(String path, KrollDict params, String httpMethod, final KrollFunction callback){
public void requestWithGraphPath(String path, KrollDict params, String httpMethod, final KrollFunction callback) {
HttpMethod method = null;
if (httpMethod == null || httpMethod.length() == 0 || httpMethod.equalsIgnoreCase("get")) {
method = HttpMethod.GET;
Expand Down Expand Up @@ -359,15 +358,15 @@ public String[] getPermissions() {
return null;
}

@Kroll.setProperty @Kroll.method
public void setLoginBehavior(String behaviorConstant) {
loginBehavior = behaviorConstant;
}
@Kroll.setProperty @Kroll.method
public void setLoginBehavior(String behaviorConstant) {
loginBehavior = behaviorConstant;
}

@Kroll.getProperty @Kroll.method
public String getLoginBehavior() {
return loginBehavior;
}
@Kroll.getProperty @Kroll.method
public String getLoginBehavior() {
return loginBehavior;
}

@Kroll.method
public void requestNewReadPermissions(String[] permissions, final KrollFunction callback) {
Expand Down Expand Up @@ -464,12 +463,11 @@ public void onError(FacebookException exception) {
@Kroll.method
public void authorize() {
Activity activity = TiApplication.getInstance().getCurrentActivity();
Log.d(TAG, "authorize called, permissions length: " + TiFacebookModule.permissions.length);
for (int i=0; i < TiFacebookModule.permissions.length; i++){
for (int i = 0; i < TiFacebookModule.permissions.length; i++){
Log.d(TAG, "authorizing permission: " + TiFacebookModule.permissions[i]);
}
if(loginBehavior != null) {
setLoginManagerLoginBehavior();
if (loginBehavior != null) {
setLoginManagerLoginBehavior();
}
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList(TiFacebookModule.permissions));
}
Expand Down Expand Up @@ -569,83 +567,73 @@ public void onSuccess(Sharer.Result results) {
break;
}

Uri uriLink = null;
Uri uriPicture = null;

if (link != null) {
uriLink = Uri.parse(link);
}

if (picture != null) {
uriPicture = Uri.parse(picture);
}

if (link != null) {
shareContent = new ShareLinkContent.Builder()
.setContentUrl(uriLink)
.setContentTitle(title)
.setContentDescription(description)
.setImageUrl(uriPicture)
.setPlaceId(placeId)
.setRef(ref)
.build();
}
shareContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(link))
.setPlaceId(placeId)
.setRef(ref)
.build();
} else {
Log.e(TAG, "The \"link\" property is required when showing a share dialog.");
}
}

if (shareDialog != null && shareDialog.canShow(shareContent, mode)) {
shareDialog.show(shareContent, mode);
}
}

@Kroll.method
public void presentInviteDialog(@Kroll.argument(optional = true) final KrollDict args)
{
AppInviteDialog appInviteDialog = new AppInviteDialog(TiApplication.getInstance().getCurrentActivity());
@Kroll.method
public void presentInviteDialog(@Kroll.argument(optional = true) final KrollDict args)
{
Log.w(TAG, "The method presentInviteDialog has been deprecated by the Facebook SDK 4.29.0 and will be removed in the future.");

AppInviteDialog appInviteDialog = new AppInviteDialog(TiApplication.getInstance().getCurrentActivity());

appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>() {
KrollDict event = new KrollDict();
@Override
public void onCancel() {
event.put(PROPERTY_SUCCESS, false);
event.put(PROPERTY_CANCELLED, true);
fireEvent(EVENT_INVITE_COMPLETE, event);
}
appInviteDialog.registerCallback(callbackManager, new FacebookCallback<AppInviteDialog.Result>() {
KrollDict event = new KrollDict();
@Override
public void onCancel() {
event.put(PROPERTY_SUCCESS, false);
event.put(PROPERTY_CANCELLED, true);
fireEvent(EVENT_INVITE_COMPLETE, event);
}

@Override
public void onError(FacebookException error) {
event.put(PROPERTY_SUCCESS, false);
event.put(PROPERTY_CANCELLED, false);
event.put(PROPERTY_ERROR, "Error inviting people");
fireEvent(EVENT_INVITE_COMPLETE, event);
}
@Override
public void onError(FacebookException error) {
event.put(PROPERTY_SUCCESS, false);
event.put(PROPERTY_CANCELLED, false);
event.put(PROPERTY_ERROR, "Error inviting people");
fireEvent(EVENT_INVITE_COMPLETE, event);
}

@Override
public void onSuccess(AppInviteDialog.Result results) {
event.put(PROPERTY_SUCCESS, true);
event.put(PROPERTY_CANCELLED, false);
fireEvent(EVENT_INVITE_COMPLETE, event);
}
});
@Override
public void onSuccess(AppInviteDialog.Result results) {
event.put(PROPERTY_SUCCESS, true);
event.put(PROPERTY_CANCELLED, false);
fireEvent(EVENT_INVITE_COMPLETE, event);
}
});

if (!appInviteDialog.canShow()) {
KrollDict errorEvent = new KrollDict();

errorEvent.put(PROPERTY_SUCCESS, false);
errorEvent.put(PROPERTY_CANCELLED, false);
errorEvent.put(PROPERTY_ERROR, "Could not show invite dialog");
fireEvent(EVENT_INVITE_COMPLETE, errorEvent);
} else {
String appLink = (String) args.get("appLink");
String appPreviewImageLink = (String) args.get("appPreviewImageLink");
if (!appInviteDialog.canShow()) {
KrollDict errorEvent = new KrollDict();

errorEvent.put(PROPERTY_SUCCESS, false);
errorEvent.put(PROPERTY_CANCELLED, false);
errorEvent.put(PROPERTY_ERROR, "Could not show invite dialog");
fireEvent(EVENT_INVITE_COMPLETE, errorEvent);
} else {
String appLink = (String) args.get("appLink");
String appPreviewImageLink = (String) args.get("appPreviewImageLink");

AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLink)
.setPreviewImageUrl(appPreviewImageLink)
.build();
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLink)
.setPreviewImageUrl(appPreviewImageLink)
.build();

appInviteDialog.show(content);
}
}
appInviteDialog.show(content);
}
}

@Kroll.method
public void presentWebShareDialog(@Kroll.argument(optional = true) final KrollDict args)
Expand Down Expand Up @@ -786,9 +774,9 @@ public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
});
}

private void setLoginManagerLoginBehavior() {
LoginManager.getInstance().setLoginBehavior(LoginBehavior.valueOf(loginBehavior));
}
private void setLoginManagerLoginBehavior() {
LoginManager.getInstance().setLoginBehavior(LoginBehavior.valueOf(loginBehavior));
}
}


1 change: 1 addition & 0 deletions ios/Classes/Like Button/FacebookLikeButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation FacebookLikeButton
- (FBSDKLikeControl *)likeButton
{
if (_likeButton == nil) {
DebugLog(@"[WARN] The LikeButton API was deprecated by Facebook in SDK 4.28.0 and later. The Ti.Facebook control will be removed in Ti.Facebook 6.0.0");
_likeButton = [[FBSDKLikeControl alloc] init];
[self addSubview:_likeButton];
}
Expand Down
30 changes: 22 additions & 8 deletions ios/Classes/Module/FacebookModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ - (void)presentWebShareDialog:(id _Nullable)unused

- (void)presentInviteDialog:(NSArray<NSDictionary<NSString *, id> *> *)args
{
DEPRECATED_REMOVED(@"Facebook.presentInviteDialog", @"5.7.0", @"5.7.0");
DebugLog(@"Facebook removed the InviteDialog API in SDK 4.28.0");

NSDictionary * _Nonnull params = [args objectAtIndex:0];

TiThreadPerformOnMainThread(^{
Expand Down Expand Up @@ -871,12 +874,12 @@ + (FBSDKShareLinkContent * _Nonnull)shareLinkContentFromDictionary:(NSDictionary

NSString *hashtag = [dictionary objectForKey:@"hashtag"];
NSString *quote = [dictionary objectForKey:@"quote"];
NSArray *to = [dictionary objectForKey:@"to"];
NSURL *contentURL = [NSURL URLWithString:[dictionary objectForKey:@"contentURL"]];
NSURL *url = [NSURL URLWithString:[dictionary objectForKey:@"link"]];
NSString *placeID = [dictionary objectForKey:@"placeID"];
NSString *referal = [dictionary objectForKey:@"referal"];

if (url == nil) {
NSLog(@"[ERROR] The \"link\" parameter is required when using share-dialogs!");
}

if (description != nil) {
NSLog(@"[WARN] Setting the \"description\" is no longer possible in Ti.Facebook 5.5.0 as part of the Graph v2.9 changes.");
NSLog(@"[WARN] It's information is scraped from the 'link' property instead, so setting it is no longer supported and will be ignored!");
Expand All @@ -900,10 +903,21 @@ + (FBSDKShareLinkContent * _Nonnull)shareLinkContentFromDictionary:(NSDictionary
[content setQuote:quote];
}

[content setContentURL:url];
[content setPeopleIDs:[dictionary objectForKey:@"to"]];
[content setPlaceID:[dictionary objectForKey:@"placeID"]];
[content setRef:[dictionary objectForKey:@"referal"]];
if (contentURL != nil) {
[content setContentURL:contentURL];
}

if (to != nil) {
[content setPeopleIDs:to];
}

if (placeID != nil) {
[content setPlaceID:placeID];
}

if (referal != nil) {
[content setRef:referal];
}

return content;
}
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion ios/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: 5.6.1
version: 5.7.0
apiversion: 2
description: Use the native Facebook iOS SDK in Axway Titanium.
author: Mark Mokryn, Ng Chee Kiat and Hans Knoechel
Expand Down
Binary file modified ios/platform/Bolts.framework/Bolts
Binary file not shown.
Binary file modified ios/platform/Bolts.framework/Info.plist
Binary file not shown.
Binary file modified ios/platform/FBSDKCoreKit.framework/FBSDKCoreKit
Binary file not shown.
Loading

0 comments on commit 377c135

Please sign in to comment.