How to send custom string with QBRTCSession object - iphone

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;

Related

Payment intent Sirikit still not working

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

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.

Having two Facebook request paths in same controller iOS SDK

I am having a controller where I need issue multiple facebook requests. How do I tell the request appart in this delegate method?
- (void)request:(FBRequest *)request didLoad:(id)result { ... }
I need to do one thing for one request and another thing for the other request.
How about write individual class request & results from delegates , i used to try this when in Single View i need to take Friends List, Checkins Data , User Info.
i ll create three separate delegate results & get results back .
However making multiple requests will work but it will create bad performances when any one of the requests failed or goes wrong.
Hope it helps
Updated :
userInfo *uInfo = [UserInfo alloc]init];
[uinfo getuserDetails];
[uInfo release];
create a protocol to return results of user info back to view class like
In UsuerInfo class
-(void)request:(FBRequest *)request didLoad:(id)result {
[delegate finfinishedGettingUserInfoDetails:result] // convert to array
}
IN your view class get back the results as
-(void)finishedGettingUserInfoDetails : (NSMutableArray *)userArr {
yourInstanceArray = [userArr copy];
}
do this for all multiple requests.

How to use Three20 framework to upload multiple images and handle JSON response?

So I have an iPhone application that needs to:
Post several strings and up to 5 images (stored in memory) to a RoR web application
Parse the JSON returned that will include several strings and an array of URLs (each representing the location of where the uploaded images can be found on the website).
QUESTIONS:
Can this be done with Three20 (would be nice since I'm using it for other things)? And if so, how?
If it can't be done with Three20 ... how would it be accomplished using ASIHttpRequest? Or maybe something baked into the SDK if that is a better option?
Thanks much
Unfortunately there isn't a whole lot of tutorials and good documentation for three20 out there on the web ... so here is how I finally got things working:
- (void) sendToWebsite {
NSString* url = [[NSString stringWithFormat:kRequestURLPath, self.entityId] stringByAppendingString:#".json"] ;
// Prep. the request
TTURLRequest* request = [TTURLRequest requestWithURL: url delegate: self];
request.httpMethod = #"POST";
request.cachePolicy = TTURLRequestCachePolicyNoCache;
// Response will be JSON ... BUT WHY DO I NEED TO DO THIS HERE???
request.response = [[[TTURLJSONResponse alloc] init] autorelease];
// Set a header value
[request setValue:[[UIDevice currentDevice] uniqueIdentifier] forHTTPHeaderField:#"Device-UID"];
// Post a string
[request.parameters setObject:self.entity_title forKey:#"entity_title"];
// Post some images
for (int i = 0; i < [self.photos count]; i++) {
// IS IT POSSIBLE TO ADD A PARAM NAME SO I CAN LOOK FOR THE SAME NAME
// IN THE WEB APPLICATION REGARDLESS OF FILENAME???
[request addFile:UIImagePNGRepresentation([self.winnerImages objectAtIndex:i])
mimeType:#"image/png"
fileName:[NSString stringWithFormat:#"photo_%i.png", i]];
}
// You rails guys will know what this is for
[request.parameters setObject:#"put" forKey:#"_method"];
// Send the request
[request sendSynchronously];
}
Things I still don't understand (or find problematic):
For a posted file, how can I include both a param name AND a filename?
What is the purpose of setting request.response = to whatever? I don't get that.
Answering #2:
You need to supply the handler for the response before you send your request, the TTURLJSONResponse is not the actual response, but it's responsible for handling the response. This is where you'd process the response for your strings and array of URLs.
It's really a protocol called TTURLResponse that defines the following method for implementation:
/**
* Processes the data from a successful request and determines if it is valid.
*
* If the data is not valid, return an error. The data will not be cached if there is an error.
*
* #param request The request this response is bound to.
* #param response The response object, useful for getting the status code.
* #param data The data received from the TTURLRequest.
* #return NSError if there was an error parsing the data. nil otherwise.
*
* #required
*/
- (NSError*)request:(TTURLRequest*)request
processResponse:(NSHTTPURLResponse*)response
data:(id)data;
You chose TTURLJSONResponse as your handler, which is a straight-forward implementation to look at for help on writing your own.