I'm using TWTRComposerViewController to share video on twitter my landscape app, it is working fine in all other device's except iPhone-X , when i try to share video in iPhone-X then composer not showing and the App freezes out.
I'm using the below written code:
if ([[Twitter sharedInstance].sessionStore hasLoggedInUsers])
{
dispatch_async(dispatch_get_main_queue(), ^{
TWTRComposerViewController *composer = [[TWTRComposerViewController emptyComposer] initWithInitialText:#"Testing" image:nil videoURL:url];
composer.delegate = self;
[self presentViewController:composer animated:true completion:nil];
});
}
else
{
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session) {
dispatch_async(dispatch_get_main_queue(), ^{
TWTRComposerViewController *composer = [[TWTRComposerViewController emptyComposer] initWithInitialText:#"Testing" image:nil videoURL:url];
composer.delegate = self;
[self presentViewController:composer animated:true completion:nil];
});
} else {
NSLog(#"Error");
}
}
The glitch you are encountering with the TWTRComposerViewController is not your error, nor are you the only one dealing with this.
This is a bug in Twitter's SDK.
Looking into Twitter's recent activity / attention to their SDK it seems their interface packages are lagging ever since the new iPhone X release. I would expect this to be resolved sooner than later.
I guess the best temporary solutions would be to either force your controller into portrait mode during this process, disable rotation for the appropriate controllers, or (though perhaps too ugly) present this VC in portrait, and rotate the view. Nonetheless, hopefully Twitter updates their SDK soon.
Report this as a bug to Twitter on their developer forum to let them know about the issue, as they should eventually see the numerous posts of the same issue...
I want the App to show all leaderboard when a user logs into the Game Center. I wrote the following code to do that, and it works OK until I once disconnected the network.
The App started without network, but local Game Center was logged in. When I reconnected the network and tapped to show leaderboards, it showed "No data available". I must terminate and reopen the App to make it work.
Oddly enough, if I added setLeaderboardIdentifier and did the same thing above, the specified leaderboard could be shown after network connected again.
Anything Wrong? Thanks
- (void)showGameCenter{
GKGameCenterViewController *gameView = [[GKGameCenterViewController alloc] init];
if(gameView != nil){
gameView.gameCenterDelegate = self;
[gameView setViewState:GKGameCenterViewControllerStateLeaderboards];
[gameView setLeaderboardTimeScope:GKLeaderboardTimeScopeAllTime];
// //[gameView setLeaderboardIdentifier:#"xxxxxxxxx"];
[self presentViewController: gameView animated: YES completion:nil];
}
}
The following is my implemented GameCenter Leaderboards code...
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
if (viewController != nil) {
[self presentViewController:viewController animated:YES completion:nil];
LBs.hidden=NO;
}
else {
}
if ([GKLocalPlayer localPlayer].authenticated) {
GameCenter = YES;
}
else {
GameCenter = NO;
}
};
The above code is nothing special, it only lets you open up Game Center and check leaderboards. Then when you click on YOUR score and then SHARE button, it sends it to Twitter (for example). The message on Twitter is "Check Out my score on HighScore playing JungleJim".
However, I want a custom message that includes the HighScore number of the player. How do I change that Shared button to include a custom message on Twitter/Facebook accounts. I don't mean for the user to type up the message. I mean for the message to pop up already there with the highscore number.
Do I have to include code in the above code or somewhere else completely?
I am unfamiliar with game-center-leaderboard, but as for sharing on facebook with the FB iOS SDK, most likely what is implemented in the backend is a share dialog (https://developers.facebook.com/docs/sharing/ios#share_dialog). This as you can see doesn't allow, as CBroe suggested, for pre-populated text in the SDK's UI.
That being said, if there's a way in game-center-leaderboard to override this behavior and share using open graph stories, you could achieve a custom text like: Chris scored a high score using myApp
https://developers.facebook.com/docs/sharing/ios#open_graph
I'm currently developing a turn based game using Game Center to handle the online functionalities (for matchmaking and turns handling).
I'm using two sandbox accounts - one on my 3gs and one on the ios Simulator.
I've been testing my app using the GKTurnBasedMatchMakerViewController to do the match making for a while without any problems, but I'm now stuck with an issue:
Every time I want to invite another player for a new (with either one or the other player), the GKTurnBasedMatchMakerViewController displays a UIAlertView stating :
Could not create game - Please remove an existing game and try again.
The thing is, I've deleted all the matches for each player (none of them has any game in his list (not even a closed game). So none of the user is in any match at the moment.
In my GKTurnBaseMatchMakerViewControllerDelegate the turnBasedMatchmakerViewController:didFailWithError: is not called.
The only called function called in the delegate- when I click the OK button on the UIAlertView - is turnBasedMatchmakerViewControllerWasCancelled:
The only thing I can think of is that my games are actually not removed from GameCenter, but as I'm removing them using the GKMatchMakerViewController UI, I barely think so.
When quitting from a turn-based match I've implemented the turnBasedMatchmakerViewController:playerQuitForMatch: like this:
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController playerQuitForMatch:(GKTurnBasedMatch *)match
{
if ( [self isLocalPlayerCurrentPlayerForMatch:match] ) {
NSData* endData = match.matchData;
for (GKTurnBasedParticipant* participant in match.participants) {
participant.matchOutcome = GKTurnBasedMatchOutcomeWon;
}
match.currentParticipant.matchOutcome = GKTurnBasedMatchOutcomeLost;
[match endMatchInTurnWithMatchData:endData
completionHandler:^(NSError *error) {
if (error) {
NSLog(#"%#",error.description);
}
}];
}
}
(NB: I only have two players in the game)
where isLocalPlayerCurrentPlayerForMatch is:
- (BOOL) isLocalPlayerCurrentPlayerForMatch:(GKTurnBasedMatch*)match
{
return [[[GKLocalPlayer localPlayer] playerID] isEqualToString:match.currentParticipant.playerID];
}
Has anyone encountered and found a solution to this issue?
Am I doing something wrong here, or is it so obvious I just can't see it?
Thank you very much for any comments that would help me find the root of that issue.
Update
Thanks to #kaan-dedeoglu I managed to know that both users had an empty list of matches (consistent with the displayed state).
I also created a third Sandbox account.
Naming the two first accounts A and B, C the third one.
State 1:
A and B are not linked to any match.
A and B are both getting the "Could not create game" error while creating any game (A invites B, A||B invites other player, A||B creates new automatch).
State 2:
C (working account) can invite B and normally plays a party with B.
C (working) can invite B for another simultaneous party
C (working) invites A to play.
A can't play (can't access the list of current matches, the GKTurnBasedMatchMakerViewController directly goes to the creation of a new game).
C is not working anymore.
A, B and C are now stuck in "Could not create game" error.
As a complement here is how I initialize my GKTurnBasedMatchMakerViewController, but I don't see that being wrong.
- (void) displayMatchMakerVC
{
if (! [[GKLocalPlayer localPlayer] isAuthenticated] ) return;
GKMatchRequest* request = [[[GKMatchRequest alloc] init] autorelease];
int nbPlayers = 2;
request.minPlayers = nbPlayers;
request.maxPlayers = nbPlayers;
GKTurnBasedMatchmakerViewController* matchMakerVC = [[[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
matchMakerVC.turnBasedMatchmakerDelegate = self;
matchMakerVC.showExistingMatches = YES;
[[CCDirector sharedDirector] presentModalViewController:matchMakerVC animated:YES];
}
NB: I'm not using ARC, could that be related to a memory issue? I'm not really a memory management guru, but it seems correct to my understanding.
Any idea of how this could be related to my code and not to game center?
Thank you very much for any answer that could help me go further.
Update 2: turnbasedMatchmakerViewController:didFindMatchMethod:
Here's my turnbasedMatchmakerViewController:didFindMatchMethod: method.
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{
BLTheme* theme = [[[BLGameConfig sharedConfig] localPlayer] userTheme];
GameSceneRemoteGCLoader* loader = [[GameSceneRemoteGCLoader alloc] initWithGKMatch:match andTheme:theme];
[viewController dismissViewControllerAnimated:NO completion:^{}];
[[CCDirector sharedDirector] replaceScene:loader];
}
When I'm launching an automatch it's launching the exact same error "Could not create game - Please remove an existing game and try again.".
This may or may not be the solution to your problem, but I had a similar issue and solved it in the following way.
It seems that either by default, or somehow, Game Center treats apps with differing CFBundleVersion (build number, not version number, or CFBundleShortVersionString) values as incompatible with one another, and thus does not show matches between apps with incremented build numbers. (Often, developers increment this number as new ad hoc builds or stable releases are distributed during development, so this is quite unfortunate).
To find and remove the "missing" games, I decremented my CFBundleVersion value (which revealed the games), and then deleted the offending matches.
Alternatively, tweaking some settings in iTunes Connect seems to have removed this CFBundleVersion incompatibility. It takes a while to propagate, but I think what did it was tapping on my app, tapping on View Details, making sure the Game Center switch is set to "Enabled", and making sure there is an item in the "Multiplayer Compatibility" table. You could also play with the possibilities within the "Manage Game Center" button from the original app screen, but I think the "Multiplayer Compatibility" setting is what finally allowed me to see all the "old" matches that were previously hidden.
Good luck!
Just to make sure: In both these devices, add these lines in your authentication completion handler and run it once. (then you can comment it out).
[GKTurnBasedMatch loadMatchesWithCompletionHandler:(^)(NSArray *matches, NSError *error) {
for (GKTurnbasedMatch *match in matches) {
[match removeWithCompletionHandler:NULL];
}
}];
This will ensure that all games are removed from your playerID.
It's ridiculous . You don't have to remove an existing match to create a new match. I'm developing a game like this and it actually works.
The following worked for me. First I ran the app on the device for each player, calling quitAllMatches. Then I ran the app again on each device, calling removeAllMatches.
In the long run, it has to be better to clean them up as you go along. But this solved the immediate problem.
-(void) quitAllMatches {
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray* matches, NSError* error) {
for (GKTurnBasedMatch* match in matches) {
GKTurnBasedParticipant* participant = match.currentParticipant;
NSString* playerID = participant.playerID;
NSString* localPlayerID = [GKLocalPlayer localPlayer].playerID;
if ([playerID isEqualToString: localPlayerID]) {
NSArray* participants = match.participants;
for (GKTurnBasedParticipant* participant in participants) {
participant.matchOutcome = GKTurnBasedMatchOutcomeTied;
}
NSData* data = [NSData data];
[match endMatchInTurnWithMatchData: data completionHandler:^(NSError* error) {
if (error) {
WJLog(#"did not end -- error %#", [error localizedDescription]);
}
else {
WJLog(#"match ended!");
}
}];
}
}
}];
}
-(void) removeAllMatches {
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray* matches, NSError* error) {
for (GKTurnBasedMatch* match in matches) {
[match removeWithCompletionHandler:^(NSError* error) {
if (error) {
WJLog(#"error: %#", [error localizedDescription]);
}
else {
WJLog(#"removed match");
}
}];
}
}];
}
I am adding Game Center functionality to my app. On the simulator, the app registers and loads the high scores perfectly from the Game Center app and the Leaderboard View in my app. When I try the same thing from an actual device,the console says the score was submitted but the score does not show up in the Game Center App or in the Leaderboard View in my app. No idea why this would be. Any Help would be great. Here is my code on how I am implementing this.
My View Did Load
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
if (error ==nil) {
NSLog(#"Success");
} else {
NSLog(#"Fail");
}
}];
How I am submitting my score
-(IBAction)submitMyScore{
//This is the same category id you set in your itunes connect GameCenter LeaderBoard
GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:#"01"] autorelease];
myScoreValue.value = score;
[myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
if(error != nil){
NSLog(#"Score Submission Failed");
} else {
NSLog(#"Score Submitted");
}
}];
}
Anyone have any idea why this is?
I fixed the Issue. I logged out of my game center account and then started the game. It prompted me to create a new game center account and I did. It then put me into sandbox mode and allowed me to view and post scores.