diff --git a/android/build.gradle b/android/build.gradle index dcf9f491..5502ea92 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,5 +6,5 @@ buildscript { } dependencies { - implementation 'com.facebook.android:facebook-android-sdk:9.0.0' + implementation 'com.facebook.android:facebook-android-sdk:13.1.0' } diff --git a/android/manifest b/android/manifest index 02cb38d0..62520cc0 100644 --- a/android/manifest +++ b/android/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 11.0.2 +version: 11.1.0 apiversion: 4 architectures: arm64-v8a armeabi-v7a x86 x86_64 description: facebook diff --git a/android/src/facebook/TiFacebookModule.java b/android/src/facebook/TiFacebookModule.java index 82da3aa0..26d7ee6c 100644 --- a/android/src/facebook/TiFacebookModule.java +++ b/android/src/facebook/TiFacebookModule.java @@ -34,13 +34,9 @@ import com.facebook.login.LoginManager; import com.facebook.login.LoginResult; import com.facebook.share.Sharer; -import com.facebook.share.model.GameRequestContent; -import com.facebook.share.model.GameRequestContent.ActionType; -import com.facebook.share.model.GameRequestContent.Filters; import com.facebook.share.model.ShareLinkContent; import com.facebook.share.model.SharePhoto; import com.facebook.share.model.SharePhotoContent; -import com.facebook.share.widget.GameRequestDialog; import com.facebook.share.widget.ShareDialog; import com.facebook.share.widget.ShareDialog.Mode; import java.math.BigDecimal; @@ -165,7 +161,7 @@ public class TiFacebookModule extends KrollModule implements OnActivityResultEve private static TiFacebookModule module; private static String[] permissions = new String[] {}; - private LoginBehavior loginBehavior; + private LoginBehavior loginBehavior = LoginBehavior.NATIVE_WITH_FALLBACK; private KrollFunction permissionCallback = null; @@ -827,115 +823,6 @@ public void onSuccess(Sharer.Result results) } } - @Kroll.method - public void presentSendRequestDialog(@Kroll.argument(optional = true) final KrollDict args) - { - GameRequestDialog requestDialog = new GameRequestDialog(TiApplication.getInstance().getCurrentActivity()); - requestDialog.registerCallback(callbackManager, new FacebookCallback() { - KrollDict data = new KrollDict(); - public void onSuccess(GameRequestDialog.Result result) - { - final String postId = result.getRequestId(); - if (postId != null) { - data.put(PROPERTY_RESULT, postId); - } - data.put(PROPERTY_SUCCESS, true); - data.put(PROPERTY_CANCELLED, false); - fireEvent(EVENT_REQUEST_DIALOG_COMPLETE, data); - } - - public void onCancel() - { - data.put(PROPERTY_SUCCESS, false); - data.put(PROPERTY_CANCELLED, true); - fireEvent(EVENT_REQUEST_DIALOG_COMPLETE, data); - } - - public void onError(FacebookException error) - { - data.put(PROPERTY_SUCCESS, false); - data.put(PROPERTY_CANCELLED, false); - data.put(PROPERTY_ERROR, "Error sending Game Request"); - fireEvent(EVENT_REQUEST_DIALOG_COMPLETE, data); - } - }); - - String title = (String) args.get("title"); - String message = (String) args.get("message"); - @SuppressWarnings("unchecked") - Map data = (Map) args.get("data"); - String recipients = (String) args.get("recipients"); - String suggestions = (String) args.get("recipientSuggestions"); - String objectID = (String) args.get("objectID"); - - String to = (String) args.get("to"); - if (to != null) { - Log.w(TAG, "Property `to` is deprecated. Please use `recipients`."); - } - - int actionTypeChoice = args.optInt("actionType", TiFacebookModule.ACTION_TYPE_NONE); - ActionType actionType; - switch (actionTypeChoice) { - case TiFacebookModule.ACTION_TYPE_SEND: - actionType = ActionType.SEND; - break; - case TiFacebookModule.ACTION_TYPE_TURN: - actionType = ActionType.TURN; - break; - case TiFacebookModule.ACTION_TYPE_ASK_FOR: - actionType = ActionType.ASKFOR; - break; - default: - case TiFacebookModule.ACTION_TYPE_NONE: - actionType = null; - break; - } - - int filtersChoice = args.optInt("filters", TiFacebookModule.FILTER_NONE); - Filters filters; - switch (filtersChoice) { - case TiFacebookModule.FILTER_APP_NON_USERS: - filters = Filters.APP_NON_USERS; - break; - case TiFacebookModule.FILTER_APP_USERS: - filters = Filters.APP_USERS; - break; - default: - case TiFacebookModule.FILTER_NONE: - filters = null; - break; - } - - String dataString = null; - if (data != null) { - dataString = data.toString(); - } - - List recipientsList = null; - if (recipients != null) { - String[] recipientsArray = recipients.split(","); - recipientsList = Arrays.asList(recipientsArray); - } - - List suggestionsList = null; - if (suggestions != null) { - String[] suggestionsArray = suggestions.split(","); - suggestionsList = Arrays.asList(suggestionsArray); - } - - GameRequestContent content = new GameRequestContent.Builder() - .setTitle(title) - .setMessage(message) - .setData(dataString) - .setRecipients(recipientsList) - .setActionType(actionType) - .setObjectId(objectID) - .setFilters(filters) - .setSuggestions(suggestionsList) - .build(); - requestDialog.show(content); - } - @Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { diff --git a/apidoc/Facebook.yml b/apidoc/Facebook.yml index 8f3fbd61..626e7a9e 100644 --- a/apidoc/Facebook.yml +++ b/apidoc/Facebook.yml @@ -282,40 +282,6 @@ description: | For details on the Share dialog, see the [official Facebook Share Dialogs documentation](https://developers.facebook.com/docs/sharing/reference/share-dialog). - ### Game Requests Dialog - - To send a game request to a user, call the - [presentSendRequestDialog()](Modules.Facebook.presentSendRequestDialog) method and pass the - method a dictionary with the `message` property set the message you want to send the invited user. - Optional: You can set the `title` property with a title string. You can also set the `data` property - with a dictionary of custom parameters. If you want to preselect users to send invite to, you can set - the `to` property with string of values that are facebook ids seperated by comma. - - To monitor if the request succeeded or not, listen to the event. - - ``` javascript - fb.addEventListener('requestDialogCompleted', function (e) { - if (e.success) { - Ti.API.info('request succeeded.'); - } else { - Ti.API.warn('Failed to share.'); - } - }); - - fb.presentSendRequestDialog({ - message: 'Go to https://appcelerator.com/', - title: 'Invitation to Appcelerator', - recipients: ['123456789', '987654321'], - data: { - badge_of_awesomeness: '1', - social_karma: '5' - } - }); - ``` - - For details on game request dialogs see the - [official Facebook Request Dialogs documentation](https://developers.facebook.com/docs/games/services/gamerequests). - ### Messenger Button The Messenger button provides a quick mechanism for users to share content to the Facebook Messenger. @@ -491,19 +457,6 @@ methods: type: SharePhotoContentParams since: "7.4.0" - - name: presentSendRequestDialog - summary: | - Opens an App Request dialog. - description: | - A `requestDialogCompleted` event is generated to indicate if the request attempt was successful or unsuccessful, - and the resultURL. - parameters: - - name: params - summary: | - A dictionary object containing parameters. - type: RequestDialogParams - since: "4.0.0" - - name: refreshPermissionsFromServer summary: Makes a request to Facebook to get the latest permissions granted. description: | diff --git a/test/unit/specs/module.spec.js b/test/unit/specs/module.spec.js index 5f95dbd8..ef9c598b 100644 --- a/test/unit/specs/module.spec.js +++ b/test/unit/specs/module.spec.js @@ -408,12 +408,6 @@ describe('ti.facebook', () => { }); }); - describe('#presentSendRequestDialog(params)', () => { - it('is a function', () => { - expect(Facebook.presentSendRequestDialog).toEqual(jasmine.any(Function)); - }); - }); - describe('#presentShareDialog(params)', () => { it('is a function', () => { expect(Facebook.presentShareDialog).toEqual(jasmine.any(Function));