I'm a newbie iOS developer, currently working on a board game. I would like to integrate UIGameKit, but I'm having trouble. It seems to always fail to auto-match, and invite friends...
I did check the build bundle id, and i've enabled gc in itunes connect, but still no luck. When I click "play now" on the device or simulator, nothing happens until it times out. When I click "invite friend", it also will fail with the following error message:
ERROR: {
GKServerStatusCode = 5008;
NSLocalizedDescription = "The requested operation could not be completed due to an error communicating with the server.";
NSUnderlyingError = "Error Domain=GKServerErrorDomain Code=5008 \"The operation couldn\U2019t be completed. status = 5008, missing required key: self-push-token\" UserInfo=0xae53360 {GKServerStatusCode=5008, NSLocalizedFailureReason=status = 5008, missing required key: self-push-token}";
I don't understand what gamekit required key am I missing? What is the self-push-token the error message is asking for?
(Editors Remark: Don't think below code is relevant, will leave here anyways)
GKMatchRequest* request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
GKMatchmakerViewController* hostVC = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
if (hostVC != nil)
{
hostVC.matchmakerDelegate = self;
[self presentViewController:hostVC];
}
Can any help? I tried to find some good samples to build a simple gamekit auto-match app but didn't have any luck, does anyone have a suggestion for me?
Related
I have been working on an app were I try to implement the requestPaymentIntent. It was working first, but at some point it started doing the Bing search, and at some point just saying it found a mistake and doing nothing after that. This has been pointed out also in the topic: Payment domain intent is showing internet result instead of intent UI or intent confirmation using Sirikit.
One solution marked as good was provided there by William Hindenburg: "We have found that you need to add a paymentRecord to the INSendPaymentIntentResponse, before returning it from the confirm and handle methods in the Payment Intent Handler. Give this a shot and see if that fixes it for you."
I have tried to do this, but I can't figure it out. I have mainly problems with defining the status.
So in my handle method I first define the userActivity. Then I initialise the response object.
let response = INRequestPaymentIntentResponse (code: .success, userActivity: userActivity)
Then I want to add a paymentRecord to the response object:
response.paymentRecord = INPaymentRecord(payee: nil, payer: nil, currencyAmount: intent.currencyAmount, paymentMethod: nil, note: intent.note, status: ???)
Some parameters I do not need/use, so I filled in nil. Two things I would like to have in my app, the amount that needs to be paid, and for what this needs to be paid (the note). On the place of the ??? I have to fill in a status, I tried several things, but I can't figure it out. Since multiple people got this working already, can you please help me to explain how this works? Thanks a lot!
Apple really doesn't specify what status to use for confirm, but this works for me currently.
Confirm call:
response.paymentRecord = [self makePaymentRecordForIntent:intent withStatus:INPaymentStatusPending];
Send call:
intentResponse.paymentRecord = [self makePaymentRecordForIntent:intent withStatus:INPaymentStatusCompleted];
Genericized code:
-(INPaymentRecord *)makePaymentRecordForIntent:(INSendPaymentIntent *)intent withStatus:(INPaymentStatus)status {
INPaymentMethod *payMethod = [[INPaymentMethod alloc] initWithType:INPaymentMethodTypeChecking
name:#"Gold Star Checking"
identificationHint:#"1234"
icon:nil];
INPersonHandle *senderHandle = [[INPersonHandle alloc] initWithValue:#"first.last#example.com" type:INPersonHandleTypeEmailAddress];
NSPersonNameComponents *senderNameComp = [[NSPersonNameComponents alloc] init];
senderNameComp.givenName = #"First";
senderNameComp.familyName = #"Last";
INPerson *senderPerson = [[INPerson alloc] initWithPersonHandle:senderHandle
nameComponents:senderNameComp
displayName:#"First Last"
image:nil
contactIdentifier:nil
customIdentifier:nil];
INPaymentRecord *paymentRecord = [[INPaymentRecord alloc] initWithPayee:intent.payee
payer:senderPerson
currencyAmount:intent.currencyAmount
paymentMethod:payMethod
note:intent.note
status:status];
return paymentRecord;
}
I have integrated the Google Plus iOS SDK v1.2.1 into my iOS app. After authentication I am trying to fetch the user's activity feed. My code is the following:
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
plusService.retryEnabled = YES;
GTLQueryPlus *query = [GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:kGTLPlusCollectionPublic];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *data,
NSError *error) {
for (GTLPlusActivity *activity in data.items) {
// ITERATE THROUGH THE ACTIVITIES
NSString *publishedDate = activity.published; <---- ERROR
// "PROPERTY 'published' CANNOT BE FOUND
// IN FORWARD CLASS OBJECT "GTLPLusActivity""
// WHY ARE THE VARIABLES SUCH AS published, placeName,
// title, actor etc NOT ACCESSIBLE
}
}];
I am able to successfully retrieve the posts of the user. The GTLPlusActivity class has many properties as shown in the image:
Whenever I try to access the properties using the "." operator such as "activity.actor" in the for loop, it gives the error "Property 'actor' cannot be found in forward class object 'GTLPlusActivity'". Why am I unable to access the properties? I need to display them in a UITableView.
EDIT: Code Snapshot. Error clearly displayed in Red.
Firstly, check the error condition and make sure the error code is nil. I have tried your code, and it works correctly on my end, so most likely, there is a problem with the response you are getting back. Generally activity.actor will return a GTLPlusActivityActor.
Try something like:
if (error) {
NSLog(#"Status: Error: %#", error);
}
else
<Do stuff>
EDIT: Also, our iOS quick-start is a great resource for seeing how we handle certain parts of the code. The ListMoments bit is pretty similar to dealing with Activities.
https://developers.google.com/+/quickstart/ios
EDIT 2: Also, make sure you have all of the right imports. Try
#import "GTLPlusActivity.h"
or
#import "GTLPlus.h"
This is my code:
// Create a service object for executing queries
GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
// Services which do not require sign-in may need an API key from the
// API Console
service.APIKey = #"AIzaSyD9pvsUtnegJvwv5z5XrBO5vFTBVpErYN8";
// Create a query
GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:#"id"];
query.maxResults = 50;
query.q = #"hiking boots";
//query.country = #"US";
// Execute the query
GTLServiceTicket *ticket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
// This callback block is run when the fetch completes
if (error == nil) {
GTLYouTubeSearchListResponse *products = object;
// iteration of items and subscript access to items.
for (GTLYouTubeSearchResult *item in products) {
//NSLog(#"%#",item.identifier); - THIS WORKS, BUT GIVES ME THE WHOLE IDENTIFIER, I JUST WANT THE VIDEO ID
NSLog(#"%#",item.identifier.videoId);
}
}else{
NSLog(#"Error: %#", error.description);
}
}];
If you'll notice the comment above my first NSLog, I'm able to print out a number of things without any issue. But if I try to print out a property of item.identifier, the app crashes completely.
The crash log is this:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTLYouTubeVideo videoId]: unrecognized selector sent
Now, item.identifier is a GTLYouTubeResourceId, so why is it thinking that I'm trying to get properties from a GTLYoutubeVideo???
Thanks for the help!
Try accessing the JSON of the identifier object directly. There appears to be a "videoId" value in there.
like this:
[item.identifier.JSON objectForKey:#"videoId"]
Now, item.identifier is a GTLYouTubeResourceId
Apparently, it isn't.
so why is it thinking that I'm trying to get properties from a GTLYoutubeVideo???
Because you wrote three consecutive question marks. Because it's a GTLYoutubeVideo instance, in fact. Sorry, C (and thus Objective-C) is not a very type-safe language. You can declare objects to be of some type, and they can be assigned a pointer to some other kind of object at runtime.
Here, I suspect you either misread something in the documentation or there's a bug in the client library or this is a weird memory management error, but one thing is sure: the runtime is always right.
I am developing iOS app, in which I have integrated authorize.net payment gateways using auth.net iOS API.
I followed each and every steps which are mentioned in their doc. Now each time, when a transaction request is sent to auth.net server on live environment it gives me error (Code E00007) i.e. "User authentication failed due to invalid authentication values".
I checked Login ID and Transaction Key and those are correct.
Even I tried with Auth.net support person, but still it did not work out.
The test enviroment and request were successful. But on Live env. it gives me the problem
My code follows:
For device registration:
Here I have put XXXX.... instead of real transaction key and login id.
MobileDeviceRegistrationRequest *mobileDeviceRegistrationRequest =
[MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest];
mobileDeviceRegistrationRequest.mobileDevice.mobileDeviceId =
[[[UIDevice currentDevice] uniqueIdentifier]
stringByReplacingOccurrencesOfString:#"-" withString:#"_"];
mobileDeviceRegistrationRequest.mobileDevice.mobileDescription = #"iPhone";
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.name = #"XXXXXXXXX";
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.password = #"XXXXXXXXXXXXXX";
[AuthNet authNetWithEnvironment:ENV_LIVE];
AuthNet *an = [AuthNet getInstance];
[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest];
After that the code for payment request:
MobileDeviceLoginRequest *mobileDeviceLoginRequest = [MobileDeviceLoginRequest mobileDeviceLoginRequest];
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name = #"XXXXX";
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password = #"XXXXXX";
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId =
[[[UIDevice currentDevice] uniqueIdentifier] stringByReplacingOccurrencesOfString:#"-" withString:#"_"];
// Set up an AuthNet instance.
[AuthNet authNetWithEnvironment:ENV_LIVE];
AuthNet *an = [AuthNet getInstance];
[an setDelegate:self];
// Process a mobile device login request.
[an mobileDeviceLoginRequest:mobileDeviceLoginRequest];
But in the initial registering request I am receiving the failure with error code E00007. Any settings I missed?
please provide the transaction key
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.transactionKey = #"XXXXXX";
it works for me
Alright I've been debugging the whole day but can't figure out what the problem is with my code.
The goal is to send a POST with RestKit to the Heroku API with a username/password to retrieve the API key.
The problem is that I'm only able to sent the request once. When sending the request the second time I get errors. (So first time I do get the API key binded to my object, but the second time just a error)
I'm using the current version of RestKit (0.10)
The code:
- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error
{
NSLog(#"didFailWithError: %#", error);
}
- (void)objectLoader:(RKObjectLoader *)objectLoader didLoadObject:(id)object
{
Account *account = (Account *)object;
NSLog(#"API_KEY: %#", account.apiKey);
}
- (IBAction) login:(id)sender
{
Account *account = [[Account alloc] init];
account.email = [emailField text];
account.password = [passwordField text];
[[RKObjectManager sharedManager] postObject:account delegate:self];
}
LOG
/// ---> FIRST CLICK
2012-05-25 14:57:00.028 HerokuApp[11154:fb03] API_KEY: 1234567890
/// ---> SECOND CLICK
2012-05-25 14:57:03.427 HerokuApp[11154:fb03] W restkit.network:RKObjectLoader.m:281 Unable to find parser for MIME Type 'text/html'
2012-05-25 14:57:03.427 HerokuApp[11154:fb03] W restkit.network:RKObjectLoader.m:309 Encountered unexpected response with status code: 200 (MIME Type: text/html -> URL: https://api.heroku.com/login -- https://api.heroku.com -- https://api.heroku.com -- https://api.heroku.com)
2012-05-25 14:57:03.429 HerokuApp[11154:fb03] didFailWithError: Error Domain=org.restkit.RestKit.ErrorDomain Code=4 "The operation couldn’t be completed. (org.restkit.RestKit.ErrorDomain error 4.)"
Can anybody help me explaining why this behaviour is occuring?
Perhaps the API behaves differently when you are logged in. From your log messages, it is appearing to return back text/html content, and not something that RestKit knows how to deal with.
Run in the simulator on a machine where Wireshark is capturing packets. Reproduce the error, then find the TCP stream where this is happening and look at it. If you need help, update your question with the result of "Follow Stream" in Wireshark so that we can see the full HTTP traffic.