Skip to content

App crashing on device but ok on simulators #318

Open
@ajonno

Description

@ajonno

Really need someone's help to figure this one out. Our app has started crashing on device, but during dev all is good on sims.

Narrowed it down to the listenForAuth method in XCode where the exception is being thrown - specifically it's the "userTokenError" event.

Firstly how should we be protecting against this crash scenario ? Im assuming we need to call reauthenticateWithCredentialForProvider() ? If yes, not sure where to put that call, in relation to the "listenForAuth" listener which we invoke on app startup (in an action).

Appreciate anyone's help/guidance on this, thanks.

RCT_EXPORT_METHOD(listenForAuth)
{
    self->listening = true;
    self->authListenerHandle =
    [[FIRAuth auth] addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth,
                                                    FIRUser *_Nullable user) {

        if (user != nil) {
            // User is signed in.
            [self userPropsFromFIRUserWithToken:user
                                    andCallback:^(NSDictionary *userProps, NSError * error) {
                                        if (error != nil) {
                                            [self
                                             sendJSEvent:AUTH_CHANGED_EVENT
                                             props: @{
                 **crashing here ====>**  @"eventName": @"userTokenError",
                                                      @"authenticated": @((BOOL)false),
                                                      @"errorMessage": [error localizedFailureReason]
                                                      }];
                                        } else {
                                            [self
                                             sendJSEvent:AUTH_CHANGED_EVENT
                                             props: @{
                                                      @"eventName": @"user",
                                                      @"authenticated": @((BOOL)true),
                                                      @"user": userProps
                                                      }];
                                        }
                                    }];

Activity

ajonno

ajonno commented on Mar 25, 2017

@ajonno
Author

any ideas on how to manage this ? im assuming token needs to be refreshed?? what is the order of precedence re auth - when should i be calling 'reauthenticateWithCredentialForProvider' ?

ajonno

ajonno commented on Mar 27, 2017

@ajonno
Author

Ari are you there ?! This is a big issue for us as app is due to go into beta at a number of schools tomorrow. Is a showstopper. Can you please help ?

jeveloper

jeveloper commented on Mar 30, 2017

@jeveloper

Hey @auser Just curious if you are still maintaining this lib?
Appreciate your efforts !

kelvinpompey

kelvinpompey commented on Apr 10, 2017

@kelvinpompey

I've run into this issue as well.

kelvinpompey

kelvinpompey commented on Apr 10, 2017

@kelvinpompey

I've worked around it by removing the call to [error localizedFailureReason].

    if (user != nil) {
        // User is signed in.
        [self userPropsFromFIRUserWithToken:user
                                andCallback:^(NSDictionary *userProps, NSError * error) {
                                    if (error != nil) {
                                        [self
                                         sendJSEvent:AUTH_CHANGED_EVENT
                                         props: @{
                                                  @"eventName": @"userTokenError",
                                                  @"authenticated": @((BOOL)false),
                                                  @"errorMessage": @"Mysterious Error"
                                                  }];
KrauseFx

KrauseFx commented on May 17, 2017

@KrauseFx

I also ran into this problem, and submitted a PR #340

This has been pretty hard to track down, as I couldn't reproduce the problem.

Salakar

Salakar commented on May 27, 2017

@Salakar
Collaborator

@ajonno @jeveloper @kelvinpompey - see my response in PR #340 - I know some of you are already doing so though now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jeveloper@kelvinpompey@KrauseFx@ajonno@Salakar

        Issue actions

          App crashing on device but ok on simulators · Issue #318 · fullstackreact/react-native-firestack