Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXC_BAD_ACCESS Upon Logging in #7

Open
joshim5 opened this issue Mar 23, 2015 · 12 comments
Open

EXC_BAD_ACCESS Upon Logging in #7

joshim5 opened this issue Mar 23, 2015 · 12 comments

Comments

@joshim5
Copy link

joshim5 commented Mar 23, 2015

Hello,

In UberKitDemo, I get an EXC_BAD_ACCESS after login:sender is called. This is after inserting the correct clientId, clientSecret, etc.

Perhaps this is an issue relating to the new API updates -- any thoughts?

It is clear to me that the issue occurs in [uberKit startLogin].

Best,

Joshua

@sachinkesiraju
Copy link
Owner

Hi @joshim5,
I tried running the app and it worked just fine for me. Could you share some of your code, it's possible that you're calling an object that hasn't been initialized correctly.
Also, have you tried adding breakpoints before the method call?

Sachin

@joshim5
Copy link
Author

joshim5 commented Mar 23, 2015

Hi Sachin,

Thanks for the quick response. What redirect_uri are you using?

Best,
Josh

@hpogosyan
Copy link

@joshim5 What should be used for the redirect_uri?

@sachinkesiraju
Copy link
Owner

@joshim5 @hpogosyan The redirect_uri according to the API documentation for a mobile app is supposed to go to your server that would have a special redirect back to your app.
The redirect URL in the iOS app can be created by adding a URL type in the info section of your app's target as shown in the screenshot below.
screen shot 2015-04-03 at 12 31 46 am
The login flow would thus be:
Login completion -> your own server (such as Heroku as Uber only accepts URIs as https) -> iOS app redirect URL (uberkit:// in this case)

Once you successfully login you should receive a callback to these delegate methods

- (void) uberKit: (UberKit *) uberKit didReceiveAccessToken: (NSString *) accessToken
{
    //Got the access token, can now make requests for user data
}
- (void) uberKit: (UberKit *) uberKit loginFailedWithError: (NSError *) error
{
    //An error occurred in the login process
}

This means that you can set any redirect URI you want in the dev portal as long as it redirects back to your app. So to answer your question, you just need to make sure that the redirect URI you're setting in UberKit is the same as the one you specify on the Uber developer portal and that your redirect URI calls your app's url type to re-enter.

Please let me know if you have any other questions regarding this.

-Sachin

@hpogosyan
Copy link

@sachinkesiraju I am using the UberKitDemo in your repo. What's the quickest way to setup a redirect_uri without actually hosting a server. Is there a service that does this?

@sachinkesiraju
Copy link
Owner

@hpogosyan To set up your own server, you could simply add an endpoint to one you already own or you could try using a service like Heroku or Paperplane.

@hpogosyan
Copy link

@sachinkesiraju I got around that issue, thank you for your help. Now I am experiencing a crash after a successful build:

http://hastebin.com/iqaheqoqod.md

I am on:
Xcode Version 6.2 (6C131e)
OS X Yosemite 10.10.2
iOS SDK 8.2

@sachinkesiraju
Copy link
Owner

@hpogosyan This a range exception which means that somewhere in your code, you are trying to access an element of an array that does not exist at the specified index.
I believe this is the method where the error is

 [uberKit getProductsForLocation:location withCompletionHandler:^(NSArray *products, NSURLResponse *response, NSError *error)
     {
         if(!error)
         {
             UberProduct *product = [products objectAtIndex:0]; //Here's where the issue is
             NSLog(@"Product name of first %@", product.product_description);
         }
         else
         {
             NSLog(@"Error %@", error);
         }
     }];

Here, you're probably getting this error because you're trying to access index 0 of products when products may be empty. Try logging products to confirm this.
This is merely a logical error and has nothing to do with an exc_bad_access or the login process.

@alihen
Copy link

alihen commented Apr 27, 2015

I'm also experiencing this issue, although intermittent. EXC_BAD_ACCESS when calling [uberKit startLoginWithViewController:self] in the UberKit Demo

@dserkin
Copy link

dserkin commented Apr 28, 2015

Same for me. There is a random crash. It happens inside of web view:

#1 0x30a671db in -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:]

You have to remove the delegate before leaving the view:
// UberKit.m file

- (void)dealloc {
    [self.loginView setDelegate:nil];
}

more details here: http://stackoverflow.com/questions/1264727/uiwebview-exc-bad-access-crash

@sachinkesiraju
Copy link
Owner

Hey guys,
Thank you so much for your feedback. I'm sorry I didn't have time to fix these bugs earlier, but I'm gonna get down to it now. There definitely seems to be an issue with the oauth flow so I'll be looking into it for the next couple of days. In case anyone's looking for an immediate solution, would everybody be cool if I replaced the login through web view with mobile safari (that worked in a previous commit)?
Thanks so much for using UberKit.
-Sachin

@pxg
Copy link

pxg commented Apr 29, 2015

@dserkin that fix worked well for me. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants