Skip to content

Commit

Permalink
Merge pull request #23 from ashcoding/MOD-2126
Browse files Browse the repository at this point in the history
[MOD-2126] Facebook: presentSendRequestDialog is missing to and title parameters
  • Loading branch information
cheekiatng committed Jun 10, 2015
2 parents 6a92ad2 + 28c052f commit 9666a04
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 15 deletions.
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 4.0.5
- fixed presentSendRequestDialog with to and title params [MOD-2126]

#### 4.0.4
- fixed photo posting for requestWithGraphPath [TIMOB-18916]
- bumped android version for parity with iOS
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,20 @@ To share more information, example:
Send Requests Dialog
--------------------
Sends an application request. Fires a `sendRequestCompleted` event. See official Facebook Dialogs documentation for more details.
Sends an application request. Fires a `sendRequestCompleted` event. You can optionally include a `title` key with the title string, or customized parameters in the `data` dictionary. To preselect users to send the invite to, you can optionally add a `to` key with a string of values containing the facebook ids, seperated by commas. See below for example.
See official Facebook Dialogs documentation for more details.
```javascript
var fb = require('facebook');
fb.presentSendRequestDialog({message: 'Go to https://appcelerator.com/'});
fb.presentSendRequestDialog({
message: 'Go to https://appcelerator.com/',
title: 'Invitation to Appcelerator',
to: '123456789, 123456788',
data: {
badge_of_awesomeness: '1',
social_karma: '5'
}
});
```
Like Button
Expand Down
5 changes: 4 additions & 1 deletion android/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
<pre>
v4.0.4 presentWebShareDialog arguments do not work as documented [MOD-2122]
v4.0.5 fixed presentSendRequestDialog with to and title params [MOD-2126]

v4.0.4 fixed photo posting for requestWithGraphPath [TIMOB-18916]
presentWebShareDialog arguments do not work as documented [MOD-2122]
bumped android version for parity with iOS [TIMOB-18916]

v4.0.3 changed minsdk to 4.0.0 [mod-2119]
Expand Down
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: 4.0.4
version: 4.0.5
apiversion: 2
architectures: armeabi armeabi-v7a x86
description: facebook
Expand Down
13 changes: 11 additions & 2 deletions android/src/facebook/TiFacebookModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import java.net.HttpURLConnection;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
Expand Down Expand Up @@ -654,6 +656,7 @@ public void presentSendRequestDialog(@Kroll.argument(optional = true) final Krol
//For example, if your app uses multiple threads, you can use the runOnUiThread() method to ensure your code
//executes on the UI thread
TiApplication.getInstance().getCurrentActivity().runOnUiThread(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
WebDialog requestsDialog = null;
Expand Down Expand Up @@ -699,11 +702,17 @@ public void onComplete(Bundle values,
})
.build();
} else {
String title = (String) args.get("title");
String message = (String) args.get("message");
String data = (String) args.get("data");
Map<String, String> data = (HashMap<String, String>) args.get("data");
String to = (String) args.get("to");
Bundle params = new Bundle();
params.putString("title", title);
params.putString("message", message);
params.putString("data", data);
if (data != null) {
params.putString("data", data.toString());
}
params.putString("to", to);
requestsDialog = (
new WebDialog.RequestsDialogBuilder(TiApplication.getAppCurrentActivity(),
Session.getActiveSession(),
Expand Down
17 changes: 15 additions & 2 deletions apidoc/Facebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ description: |
To send a 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 <Modules.Facebook.requestDialogCompleted> event.
Expand All @@ -332,7 +335,15 @@ description: |
}
});
fb.presentSendRequestDialog({message: 'Go to https://appcelerator.com/'});
fb.presentSendRequestDialog({
message: 'Go to https://appcelerator.com/',
title: 'Invitation to Appcelerator',
to: '123456789, 123456788',
data: {
badge_of_awesomeness: '1',
social_karma: '5'
}
});
For details on dialog see the
[official Facebook Request Dialogs documentation](https://developers.facebook.com/docs/games/requests/v2.2).
Expand Down Expand Up @@ -548,7 +559,9 @@ methods:
A dictionary object containing following properties:
* `message` (String): Required. Message to send with the request.
* `data` (String): Optional. Additional data to send with the request object.
* `title` (String): Optional. Title of request.
* `to` (String): Optional. String of pre-selected facebook ids, seperated by commas.
* `data` (Dictionary): Optional. Additional data to send with the request object.
type: Dictionary
since: 4.0.0

Expand Down
2 changes: 2 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log
<pre>
v4.0.5 fixed presentSendRequestDialog with to and title params [MOD-2126]

v4.0.4 fixed photo posting for requestWithGraphPath [TIMOB-18916]

v4.0.3 changed minsdk to 4.0.0 [mod-2119]
Expand Down
25 changes: 20 additions & 5 deletions ios/Classes/FacebookModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,32 @@ -(void)presentSendRequestDialog:(id)args
id params = [args objectAtIndex:0];
ENSURE_SINGLE_ARG(params, NSDictionary);
NSString *message = [params objectForKey:@"message"];
NSString *data = [params objectForKey:@"data"];
NSDictionary *additionalParams = [NSDictionary dictionaryWithObjectsAndKeys:data,@"data", nil];

NSString *title = [params objectForKey:@"title"];
NSString *to = [params objectForKey:@"to"];
id data = [params objectForKey:@"data"];
ENSURE_SINGLE_ARG_OR_NIL(data, NSDictionary);
NSMutableDictionary *additionalParams = nil;
if (data != nil) {
additionalParams = [NSMutableDictionary dictionaryWithDictionary:data];
if (to != nil) {
[additionalParams setObject:to forKey:@"to"];
}
}
else {
if (to != nil) {
additionalParams = [NSMutableDictionary dictionaryWithObject:to forKey:@"to"];
}
}


TiThreadPerformOnMainThread(^{
[FBWebDialogs presentRequestsDialogModallyWithSession:FBSession.activeSession
message:message title:nil parameters:additionalParams
message:message title:title parameters:additionalParams
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
BOOL cancelled = NO;
BOOL success = NO;
NSString *errorDescription = @"";
NSDictionary *urlParams;
NSDictionary *urlParams = nil;
if (error) {
errorDescription = [FBErrorUtility userMessageForError:error];
} else {
Expand Down
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: 4.0.4
version: 4.0.5
apiversion: 2
description: Allows facebook integration for Titanium apps
author: Mark Mokryn and Ng Chee Kiat
Expand Down
2 changes: 1 addition & 1 deletion ios/module.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

//
// How to add a Framework (example)
FRAMEWORK_SEARCH_PATHS=$(SRCROOT)/../../modules/iphone/facebook/4.0.4/platform "~/Library/Application Support/Titanium/modules/iphone/facebook/4.0.4/platform"
FRAMEWORK_SEARCH_PATHS=$(SRCROOT)/../../modules/iphone/facebook/4.0.5/platform "~/Library/Application Support/Titanium/modules/iphone/facebook/4.0.5/platform"
OTHER_LDFLAGS=$(inherited) -framework Social -framework FacebookSDK
//
// OTHER_LDFLAGS=$(inherited) -framework Foo
Expand Down

0 comments on commit 9666a04

Please sign in to comment.