Getting all the user's friends that are using the app - ios

I know that by the title this question has been asked a lot, but with the new Facebook 4.0 sdk this is a problem.
I know that if i call
[self FCMSendOpenGraphRequestWithPath:#"me/friends" andCompletionHandler:^(BOOL seccess, id result, NSError *error) {
if (seccess) {
}
}else{
}
}];
I will get all the user's friends that are using my app and that fit into one paging page (i have noticed that one page can hold 25 friends).
My problem is what happens when i need to get the page 2,3,4..etc'?
I know that if i call the graph call with the 'next' field i will get the next page. But because the Facebook sdk uses only completionHandlers using recursion won't work, and i don't want to hard code all the method call obviously.
All advices will help,
Thanks

Related

Create Pin PDKResponseObject response not consistent with documentation

We are creating a pin in a specific Board by using the method
createPinWithImageđź”—onBaord:description:progress:withSuccess:andFailure:
We read in the documentation (here: https://developers.pinterest.com/docs/api/overview/ and here: https://github.com/pinterest/ios-pdk/blob/master/Pod/Classes/PDKClient.h#L417) that this method should return a PDKResponseObject *responseObject with the ID, URL, clickthrough URL and description of the created Pin.
We have been creative enough to try to access the ID of the Pin and its URL using any possible key (#"id", #"identifier", #"url", #"NSUrl") but the values returned are always nil. In fact the PDKResponseObject returns only 2 keys: Board ID and Pin Description.
What should we do to access the ID or, at the very least, the URL of the newly created Pin?
Does anybody have the same issue?
Despite multiple attempts and after having tried to discuss this issue with the Pinterest development Team, this still remains.
Testing a solution becomes also extremely difficult considering the new limitation Pinterest has imposed on not approved apps (which include all apps under development by definition).
For now, I only found a way around by calling a new request to get all pins in a specific board and get the first in the resulting array (which is the last posted):
//Create pin in Pinterest
[[PDKClient sharedInstance]createPinWithImage:image link:urlToShare
onBoard:reference description:message progress:nil
withSuccess:^(PDKResponseObject *responseObjectCreation) {
//Previous block does not return pin id so a new call is required
[[PDKClient sharedInstance]getBoardPins:reference fields:[NSSet
setWithArray:#[#"link"]] withSuccess:^(PDKResponseObject
*responseObject) {
//Get id of last pin
NSArray *pinIDs = [[NSArray arrayWithArray:[responseObject
pins]]valueForKey:#"identifier"];
NSString *postId = [pinIDs objectAtIndex:0];
}];
}];
By the way, the right key for the pin ID is "identifier" and not "id" or "ID" as said in the API documentation. Just found out by trying multiple times and checking the Pinterest Example app in GitHub.
Hope this helps other people who are fighting the same problem.

Implement my own a custom GKTurnBasedMatchmakerViewController

I'm sure there are questions similar to this, but I couldn't find an example. I'm trying to recreate the apple GKTurnBasedMatchmakerViewController for my turn based game with my own custom interface for my turn based iphone game. I'm having trouble getting all the options to display correctly so I was hoping someone had a working example. My current code is this:
-(void)getCurrentGamesFromServer {
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error) {
if(matches){
for (GKTurnBasedMatch *myMatch in matches) {
//this is, I believe, also where we need to consider invitations. available instance methods provided by GC are: acceptInviteWithCompletionHandler and declineInviteWithCompletionHandler
if(myMatch.status == 1){ //ongoing game
if([myMatch.currentParticipant.playerID isEqualToString:[GKLocalPlayer localPlayer].playerID]){ //if it's my turn
//here we need to populate the table by adding our matches to mcurrentgamesarray. after all the matches have been added, reload the tableview
NSLog(#"active game that is my turn");
[self.mCurrentGamesArray addObject:myMatch];
}
else{
NSLog(#"other turn or an invite from another player waiting to hear from you");
}
}
}
}
[_mCurrentGamesTableView reloadData];
}];
}
As you can see, the only games I'm grabbing right now are games where the status is 1 (ongoing game) and the current participant ID is my ID.
to get games that were not my turn, I tried doing games where it was not my ID, but it included invites with it and I couldn't figure out how to separate them out.
Basically, I'd like to have a section of games where it is my turn, a section where it is not my turn but games are still active, a section of completed old games, and a section for invites. does anyone have a working example, or a page they can send me to that explains the best practices for what I'm trying to do? Thanks for your help.

Gamekit / gamecenter random matchmaking programmatically

I am trying to implement random matchmaking programmatically with my own custom userinterface.
I'm kinda stuck..
using this code found at the apple site I can create a match without problems
- (void)findProgrammaticMatch
{
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
[GKTurnBasedMatch findMatchForRequest: request withCompletionHandler:^(GKTurnBasedMatch *match, NSError *error)
{
if(error)
NSLog(#"ERROR");
if (match) {
NSLog(#"STARTING MATCH");
}
}];
}
and if I do match.participants.count I get the number 2...
but one participant is me and the other is null
What ive done to test is create 2 sandbox accounts and I ran the same code with my other game center account, and I got a new game created,.. but it didnt match them for some reason.. am I missing something?
ive been looking for examples on google, but I can't seem to find any.. if any of you know anywhere I can find some examples, I would be most grateful
Well, you might be missing out an essential point in turn based match making. When the user starts an automatch if he is not connected to an existing match it starts a fresh game and user takes the first turn. Only after HE COMPLETES HIS TURN, other users can connect to this game. So if you are making a 2 player match: one user should start a fresh game with the other user being null at that moment and the other user should connect to this existing game after the first one finished his turn (endTurnWithMatchData called)
This is not very clear in documentation (I despise the gamecenter documentation, unclear & incomplete) but it is the case for sdk 6. I think it will change in the near future.

Nice old facebook dialog posts VS iOS6 Native dialog posts

I successfully integrated Facebook SDK 3.1 in my app, and I'm trying to propose iOS6+ only features to iOS6+ users. I was able to show the share sheet, but I was quite disapointed when I saw what the post on my wall looked like. Here is an image to describe what I mean :
The first one is what is got from a pre-iOS6 dialog (the web popup), and the second one is got from the new iOS6+ Native Facebook Dialog (SLComposeViewController, in other words).
My questions are :
Is there a way to make the second post look like the first one using FacebookNativeDialog ? Is it possible to give a params Dictionary like before so the post will display correctly "via {myAppName}" ? Or is it simply the new way of showing posts, and the older way is deprecated ?
Two things:
1/ "via iOS" attribution - This is currently per design and cannot be customized for your app.
2/ Having the same look - you can get this by providing only the link when setting up the composer (i.e. don't provide the image):
SLComposeViewController *fbVC = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbVC setCompletionHandler:^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Canceled");
} else if (result == SLComposeViewControllerResultDone) {
NSLog(#"Posted");
}
}];
[fbVC addURL:[NSURL URLWithString:#"https://developers.facebook.com/ios"]];
[self presentViewController:fbVC animated:YES completion:nil];
The key to getting the same look is that the page linked to has Open Graph tags that Facebook can recognize to properly display the data. You can test if the OG tags are good by entering the link into https://developers.facebook.com/tools/debug
If the page does not have OG tags, the link will simply be displayed.

MGTwitterEngine + OAuth Load Users Tweets

I am using MGTwitterEngine + OAuth in my project. I would like to load all tweets from the currently logged in user into a NSMutableArray, however I am having difficulty doing so.
Upon successful login I call the following method:
[_engine getUserTimelineFor:_engine.username sinceID:0 startingAtPage:0 count:20];
And then in the delegate method I have the following:
- (void) statusesReceived:(NSArray *)statuses
forRequest:(NSString *) connectionIdentifier
{
for ( NSDictionary *dict in statuses )
{
NSLog(#"%#", [dict objectForKey:#"id" ]);
// tweets is a NSMutableArray previously allocated and initialised
[tweets addObject:[dict objectForKey:#"id" ]];
}
[_engine getUserTimelineFor:_engine.username sinceID:0 startingAtPage:0 count:20];
}
As you can see I am attempting to batch load the current users tweets, 20 at a time.
I believe the issue lies in the fact, I am not incrementing the page parameter. My issue is, I don't understand what a page actually represents, or how to get the total number of pages for any given user.
How can I load all of a users tweets in a simple, and efficient manner?
If you are using tableView to display tweet to user, you can use "Facebook's way". You can show first 20 tweets in the table view and when iPhone user scrolls down and and try to view last tweet (if you are rendering last row of your table view) then send request to get next 20 tweets and so on. So that you don't need to show page numbers and older tweets will get loaded when user wants to view them.
I hope this helps you.

Resources