Payment intent Sirikit still not working - swift

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;
}

Related

How to send custom string with QBRTCSession object

In my application I have implemented quickblox SDK for voice and video call and everything is working perfectly. There is just one issue which I am facing. To track the particular call in background I have a session created between two users. But while making this call I want to send the same session Id to the opponent also. If somebody could help me please tell me how could i do this.
Thanks in advance
Got the solution!!
Refer http://quickblox.com/developers/Sample-webrtc-ios
Before making a call I have following line of code written in my file
[self.session startCall:userInfo];
Here you can write anything inside userInfo dictionary. As soon as opponent receives the call
- (void)didReceiveNewSession:(QBRTCSession *)session userInfo:(NSDictionary *)userInfo
will be called. Here whatever you have written inside userInfo, you can read it directly.
[QBRTCClient.instance addDelegate:self];
// 2123, 2123, 3122 - opponent's
NSArray *opponentsIDs = #[#3245, #2123, #3122];
QBRTCSession *newSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs
withConferenceType:QBConferenceTypeVideo];
// userInfo - the custom user information dictionary for the call. May be nil.
NSDictionary *userInfo = #{ #"key" : #"value" };
[newSession startCall:userInfo];
Start call method definition says the same
/**
* Start call. Opponent will receive new session signal in QBRTCClientDelegate method 'didReceiveNewSession:userInfo:
*
* #param userInfo The user information dictionary for the stat call. May be nil.
*/
- (void)startCall:(NSDictionary *)userInfo;

Accessing GTLPlusActivity properties

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"

In the Youtube API for iPhone SDK, I'm trying to get the videoID of each search result. I'm getting an error every time though, what should I do?

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.

Can't create reminder calendar in iOS

I'm trying to create a reminder calendar so I can add and delete reminders. It is actually working well on the devices I use (iPhone 5/4S/4) but on certain client devices which are still iPhones - I'm getting this error below about the account not supporting reminders.
Here is the workflow:
* Init the event store.
* Request permission (check its granted for Reminder types) (iOS6+) for lower we just init.
* Create a new calendar, local storage, type = Reminder
* Save calendar to get its Identifier.
Works most of the time, this appears on some devices -
Error Domain=EKErrorDomain Code=24 “That account does not support reminders.”
Permissions are granted and checked under Settings, Privacy, Reminders. I can't find anything in the docs about the conditions under which you'd get this error.
Thanks!
Not sure if you still need this but here is what i ran into.
First of all i'm pretty sure that reminders cannot be set on a calendar with a local source. I kept getting the "That account does not support reminders". Even after setting all non read only properties on the calendar before committing to the event store it still didn't work. The source needs to be calDav. Then I tried Devfly's response and it didn't work either but for a different reason. It kept fetching my gmail calendar which does not allow setting reminders (i think its actually read only for events and reminders). So i used the following code to get the actual iCloud source
for (EKSource *source in sources) {
NSLog(#"source %#",source.title);
if (source.sourceType == EKSourceTypeCalDAV && [source.title isEqualToString:#"iCloud"]) {
localSource = source;
break;
}
}
This setting this source on my new reminders calendar worked for me. hope it helps someone
First, just a check: you are creating a "new calendar" (a whole calendar), not just a "new reminder", right?
Second: are you using iOS6? Reminders are available (in EventKit) only starting from iOS6: link
As commented by Jesse Rusak, this happens because you are probably creating the new calendar inside an account/source that doesn't support reminders.
How do you create the new calendar?
Do you set the source property?
the first thing you can try, is to loop all sources until you find a suitable one.
EKSourceTypeLocal supports reminders. iCal too.
Here a list of EKSourceType
typedef enum {
EKSourceTypeLocal,
EKSourceTypeExchange,
EKSourceTypeCalDAV,
EKSourceTypeMobileMe,
EKSourceTypeSubscribed,
EKSourceTypeBirthdays
} EKSourceType;
Find a suitable one:
// find local source for example
EKSource *localSource = nil;
for (EKSource *source in store.sources)
{
if (source.sourceType == EKSourceTypeLocal) // or another source type that supports
{
localSource = source;
break;
}
}
Then, create the new calendar setting the right source
EKCalendar *cal;
if (identifier == nil)
{
cal = [EKCalendar calendarForEntityType:EKEntityTypeReminder eventStore:store];
cal.title = #"Demo calendar";
cal.source = localSource;
[store saveCalendar:cal commit:YES error:nil];
}
Try and let me know
What solved my problem is not saving the calendar to the local source, but instead to EKSourceTypeCalDAV (iCloud). It works, and it's synced across all devices.
The local store may not support reminders. This is reproducible if iCloud is enabled.
This is the most reliable solution I could find, without hard-coding any assumptions:
let calendar = EKCalendar(forEntityType: .Reminder, eventStore: eventStore)
if eventStore.sources.count == 0 { // reproducible after Reset Content and Settings
calendar.source = EKSource()
}
else {
calendar.source = eventStore.defaultCalendarForNewReminders().source
}
eventStore.saveCalendar(calendar, commit: true)

why gamekit auto-match always timeout

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?