Google Places for iOS version 3 - ios

Today Google released version 3 of its Places API for iOS. Upgrading my project and using the new findPlaceLikelihoodsFromCurrentLocationWithPlaceFieldsmethod I get the following error:
"Pick Place error The operation couldn’t be completed. An internal
error occurred in the Places API library...."
Any ideas?
Here is my complete Objective C code:
GMSPlaceField fields = GMSPlaceFieldName;
GMSPlacesClient *placesClient;
placesClient = [GMSPlacesClient sharedClient];
[placesClient findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:fields callback:^(NSArray* likelihoods, NSError* error){
if(error != nil)
{
//##
NSLog(#"Pick Place error %#", [error localizedDescription]);
return;
}
for(GMSPlaceLikelihood *likelihood in likelihoods)
{
//##
NSLog(#"likelihood.place : %#",likelihood.place.name);
}
}];

Turns out Google changed things without being terribly obvious.
In my case, I used to have the "Places SDK for iOS" restriction added on the API key, but the new stuff requires the "Places API" restriction.

Related

O365 iOS Microsoft Graph SDK- How to get next page of one drive search results

I am playing with O365 iOS Microsoft Graph SDK. I am searching one drive for 'xxx', When i use the nextRequest item to get next page of the search results i get following error
2017-05-30 16:24:30.413 O365-iOS-Microsoft-Graph-SDK[36063:3959258] Graph SDK ERROR : Error from data task : Error Domain=com.microsoft.graph.errors Code=400 "bad request" UserInfo={error= invalidRequest : Invalid query option, NSLocalizedDescription=bad request}
2017-05-30 16:24:30.414 O365-iOS-Microsoft-Graph-SDK[36063:3959258] Graph SDK ERROR : Caused by request { URL: https://graph.microsoft.com/v1.0/me/drive/items/root/microsoft.graph.search(q='.xxx')?$skiptoken=MjAx(q=null) }
here is the code
MSGraphDriveItemSearchRequest *itemSearchRequest = [[[[[self.graphClient me] drive] items:#"root"] searchWithQ:#".xxx"] request];
[itemSearchRequest executeWithCompletion:
^(MSCollection *response, MSGraphDriveItemSearchRequest *nextRequest, NSError *error) {
if(!error) {
[nextRequest executeWithCompletion:
^(MSCollection *response2, MSGraphDriveItemSearchRequest *nextRequest2, NSError *error2) {
if(!error2) {
}
}];
}
}];
If i use graph explorer and use (https: //graph.microsoft.com/v1.0/me/drive/items/root/microsoft.graph.search(q='.xxx')?$skiptoken=MjAx) as query, i get the 'next' page of search results, i wonder why it is not working with the code i pasted.

Google Drive on iOS and "invalid_grant"

I have an iOS app that uses Google Drive to sync some files. The app was working fine up until a couple of months ago (it uses iCloud by default for syncing so it wasn't until recently that I learned the Google Drive since was no longer working).
The error I'm getting is:
An error occurred: Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={json={
error = "invalid_grant";
}, data=<7b0a2020 22657272 6f722220 3a202269 6e76616c 69645f67 72616e74 220a7d>}
The OAuth part sets to be OK and I think I'm authorized to access the user's Google Drive. The error happens when I try to list the files at the top level to see if I need to create a special directory for my app.
- (void)createGoogleDocumentsDirIfNeeded:(id<GoogleServiceDelegate>)delegate
{
NSString *parentID = #"root";
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = [NSString stringWithFormat:#"'%#' in parents and title = '%#' and trashed != true", parentID, APP_NAME];
[googleService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFileList *files,
NSError *error)
{
if (error == nil)
{
if ( files.items.count == 0)
{
NSLog(#"Creating google documents dir: %#", APP_NAME);
[self createGoogleDocumentsDir:delegate];
}
else
{
GTLDriveFile *file = [files objectAtIndexedSubscript:0];
self.googleDocumentsID = file.identifier;
NSLog(#"Directory exists: %#; fileID = %#", APP_NAME, googleDocumentsID);
[delegate googleDocumentsDirCreated:YES];
}
}
else
{
NSLog(#"An error occurred: %#", error);
}
}];
}
The error is displayed in the last NSLog().
I'm pretty convinced that something has change on Google's side that is causing this. I've reverted to code to a point where I know it worked before and it is still failing.
Possibly I've made some change in our Google Developer's Console that is causing this, but I can't see what.
It is also the case that the Google API Dashboard still shows some successful accesses, so it seems this is not failing for everyone.
Any thoughts as to what could be going on? The "invalid_grant" error seems pretty generic and web searches show it happens in lots of situations. Any help would be appreciated.
As you say, there could be a variety of explanations.
Some to check are:-
has the user withdrawn his permission
are you using an expired refresh token
is the phone's clock accurate
Read https://developers.google.com/identity/protocols/OAuth2UserAgent
The URL used when authenticating a user is https://accounts.google.com/o/oauth2/v2/auth. This endpoint is accessible over SSL, and HTTP connections are refused.
Only for httpS connects for now

Getting user infos using ObjectiveDropboxOfficial framework

I am using ObjectiveDropboxOfficial framework for Dropbox integration within Objective-C app (due to the deprecation of v1 dropbox api).
Framework link
I am trying to get logged in dropbox user info (email, name, etc). Here is my code:
DropboxClient *client=[DropboxClientsManager authorizedClient];
[[client.usersRoutes getCurrentAccount]
response:^_Nonnull(DBUSERSBasicAccount *response, DBError *dberror)
{
// loginLabel.text=[NSString stringWithFormat: #"%#\n%#", account.name, account.email];
return response;
}
}];
This code doesn't work and additionnally causes weird error from xcode: enter image description here
The method definition is:
- (DBRpcTask<DBUSERSBasicAccount *, DBUSERSGetAccountError *> *_Nonnull) getAccount:(NSString *_Nonnull)accountId;
- (DBRpcTask<TResponse, TError> *_Nonnull)response:
(void (^_Nonnull)(TResponse _Nullable, TError _Nullable,
DBError *_Nullable))responseBlock;
I was stuck with this for a whole day, any help would be appreciated:
1- How to get user infos using the framework, or
2- What is causing the error and how should that Nonnull method be called?
Thank you in advance
So finally after 2 days of struggling I found the response :
DropboxClient *client = [DropboxClientsManager authorizedClient];
if(client)
{
[[client.usersRoutes getCurrentAccount] response:^(DBUSERSFullAccount *account, DBNilObject *obj, DBError *error) {
if (error != nil) {
NSLog(#"Error %#", error.errorContent);
}
if (account != nil) {
NSLog(#"User's name %#", account.name.displayName);
}
if(self.hud)
[self.hud hideAnimated:YES];
}];
I hope this would save another developer's energy and mental health :)

stackmob ios datastore http 401 error

I'm using the iOS DataStore API to upload data to StackMob. I get this error when I try to use my smclient initialized with my public key.
HTTP Code=401 "The operation couldn’t be completed. (HTTP error 401.)" UserInfo=0xa14dac0 {error=Insufficient authorization}
Sample code
[[self.smclient dataStore] createObject:eventDictObj
inSchema:#"EventSchema"
onSuccess:^(NSDictionary *object, NSString *schema)
{
NSLog(#"Created online event : %#", object);
successBlock();
}
onFailure:^(NSError *error, NSDictionary* object, NSString *schema)
{
failedBlock(error);
}];
And smclient is initialized as follows
self.smclient = [[SMClient alloc] initWithAPIVersion:#"0" publicKey:#"xxxxxxxxxx"];
For this use case I don't need to use the logged in user credentials to create this entry in StackMob
Make sure that the permissions are set to Open on your stack mob database.

Fetching Current User Profile using Objective C Google Plus Client Library

I am using the Google CLient Libraries for Objective C available here..
I have successfully been able to Authorize the user and get refresh token. (Using the GTMOAuthenticaion api embedded within).
In the Selector called after successful authorization I make the Get User Profile request as follows.. (I need the id of currently loggedin/authenticated user)
-(void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (error != nil) {
NSLog(#"Stop");
} else {
if ([auth canAuthorize]){
[Mediator plusService].authorizer = auth;
// Problematic Line
GTLQueryPlus *profileQuery = [GTLQueryPlus queryForPeopleGetWithUserId:#"me"]; // Notice the UserId Param
profileQuery.completionBlock = ^(GTLServiceTicket *ticket, id object, NSError *error) {
if (error == nil) {
self.mediator.gProfile = object;
} else {
NSLog(#"GPlus Service Error %#", error);
}
};
[[Mediator plusService] executeQuery:profileQuery completionHandler:
^(GTLServiceTicket *ticket, id result, NSError *error) {
if (error)
NSLog(#"Some Service Error %#", error);
}];
}
}
}
If I put "me" as parameter, I get invalid user ID error string in jSON response.
However, If I provide some userId like my own 113632923069489732066 it works perfectly fine and returns the appropriate jSON response..!!
The Example for Google Plus inside Examples folder also fails to get current user profile ending with following error.
Error Domain=com.google.GTLJSONRPCErrorDomain Code=400 "The operation couldn’t be completed. (Invalid user ID: {0})" UserInfo=0x7a670fa0 {NSLocalizedFailureReason=(Invalid user ID: {0}), GTLStructuredError=GTLErrorObject 0x7a67b130: {message:"Invalid user ID: {0}" code:400 data:[2]}, error=Invalid user ID: {0}}
P.S. My API Console application doesn't work with iOS option under installed app but needs be configured with "Other" option. When configured with iOS option, the oAuth fails with invalid_client error response.
My Mistake .. !! And a very silly one .. !!
I was signing in using a Gmail Account that was yet not associated with GPlus .. !! =/

Resources