I am trying to send invitation to my facebook friends through my application. I have friends list of my facebook friends in my application, I used FBWeb-dialog to send invitation to my friends. After selection my friends to whom I want to send request I am sending request them and its working fine, but my problem is that they are not receiving any notification to their wall. Can anybody tell me what should I do to notify them via notification. I am attaching my code also.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[arrSelectedFriends componentsJoinedByString:#","], #"suggestions",nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:#"User X” has invited you to join demoApp,Download the free app here."
title:nil parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}
}];
Related
I was using ios friend request dialog from facebook to send invitation to user for my app. After facebook announced closing of their API it stopped working, Does anyone have an idea how to invite people for application for ios.
You can use this code.
- (void)inviteFriendsOfFacebook
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[mArrTempSelected componentsJoinedByString:#","], #"suggestions", nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:textView.text
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
}
else
{
[Helper showAlertForMessage:#"Invitation Sent Successfully." title:nil cancelButton:#"Ok" otherButton:nil andDelegate:nil withTag:0];
}
}}];
}
Facebook has announced that this will work only for Games application, though one can do this. Just set canvas url for app on Facebook app and use faecbook request dialog. This is very usefull feature for any app.Facebook is working on this feature to make available easily.
We built an IOS game and now it's in the testing process. When we tried to test the Invite Friends via Facebook in game, we found that our request only showed up in two places: 1. The Home Reminders section in the upper right hand corner of the main news feed home on the desktop web version of Faceook.com. 2. The notification jewel on the desktop web version of Faceook.com.
The inviting request NEVER appeared in the notification jewel on device( iPhone or iPad). Does anybody know what we should do? Please help us. Thank you.
Here are the codes:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// Optional parameter for sending request directly to user
// with UID. If not specified, the MFS will be invoked
[NSString stringWithCString:s.c_str() encoding:NSASCIIStringEncoding], #"to",
// Give the action object request information
//#"send", #"action_type",
#"111111111111", #"app_id",
//#"2222222222222", _#"objectid",
nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:[NSString stringWithCString:words.c_str() encoding:NSUTF8StringEncoding] title:nil parameters:params handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if(error)
{
// Error launching the dialog or sending the request.
NSLog(#"Error sending request.");
}
else
{
if(result == FBWebDialogResultDialogNotCompleted)
{
// User clicked the "x" icon
NSLog(#"User canceled request.");
}
else
{
// Handle the send request callback
if([[resultURL query] rangeOfString:#"request"].length == 0)
{
// User clicked the Cancel button
NSLog(#"User canceled request.");
}
else
{
// User clicked the Send button
//NSString *requestID = [urlParams valueForKey:#"request"];
//NSLog(#"Request ID: %#", requestID);
NSLog(#"User send request.");
}
}
}
}
];
I've implemented the basic function to send a invitation request to players' friends to play my game app on iOS devices.
I've followed the instructions here: https://developers.facebook.com/docs/ios/ios-sdk-games/requests/
Everything works fine, I can send requests and friends receive notifications. The problem is that I cannot get the request dialog to appear the way is shown in the above link, in particularly I cannot get the request's preview in the dialog. Does this depend on SDK version? I am currently running with version SDK 3.5.3. Or the problem is somewhere else? any help is greatly appreciated. Thanks
Here's the code that calls the function:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:[NSString stringWithFormat:#"Come and play CSR with me!"]
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}}];
I have an invite feature to ask friends to download App.
These are my approach
1. The approach below required canvas page which i don't have.
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:#"MCommerce - World Class App"
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}}];
Post to friends wall. I am using FeedDialog and posting to friend wall is disabled by Facebook.
Any alternate way of sending an invite to ask friend download the App?
// Display the requests dialog
[FBWebDialogs presentRequestsDialogModallyWithSession:nil message:#"Learn how to make your iOS apps social." title:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or sending the request.
NSLog(#"Error sending request.");
}
else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled request.");
}
else {
// Handle the send request callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"request"]) {
// User clicked the Cancel button
NSLog(#"User canceled request.");
}
else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:#"request"];
NSLog(#"Request ID: %#", requestID);
}
}
}
}];
To clarify, requests won't show up in users wall/feed, but rather as notifications under the "globe" icon. However, requests won't show up in the notifications if:
1) The application is in Sandbox mode, and the receiver isn't a developer on the app. (any level)
2) The user has disabled requests for the app / notifications from FB. (https://www.facebook.com/settings?tab=notifications)
From personal experience, I would also add that Facebook tends to not show notifications for requests if you spam them too much or if you have low rating for posts. (Check facebook.com/insights)