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

Fixes: #1769 #1781

Merged
merged 8 commits into from
Feb 15, 2025
Merged

Fixes: #1769 #1781

merged 8 commits into from
Feb 15, 2025

Conversation

joshijoe05
Copy link
Contributor

@joshijoe05 joshijoe05 commented Feb 10, 2025

/claim #1769
Fixes : #1769

This PR enables iOS users to log in via Google along with Apple Sign-In. It also introduces custom reusable widgets for the UI (Sign-In Buttons) , reducing dependency on external packages and making the app more self-reliant.

@joshijoe05
Copy link
Contributor Author

joshijoe05 commented Feb 10, 2025

@mdmohsin7 @beastoin Could you please take a review on this PR

Copy link
Collaborator

@mdmohsin7 mdmohsin7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button can be made using the existing SignInButton class just like it has been done in #1773

Conflict with #1773 as both solve the same
@beastoin

@joshijoe05
Copy link
Contributor Author

The button can be made using the existing SignInButton class just like it has been done in #1773

Conflict with #1773 as both solve the same

@beastoin

Yes ofc, but I created a custom sign-in button for better UI consistency and easier customization. This reduces dependency on third-party packages and gives us full control over styling and behavior.

@beastoin
Copy link
Collaborator

1/ @ibrahimnd2000 @joshijoe05 do you guys want to collaborate with each other to solve this issue. why do i ask ? i see @joshijoe05 has a good idea on getting rid of dependencies and, @ibrahimnd2000 is the first comer. it would be great if you guys can work together to solve this small issue and more importantly, working on next big issues (omi still has $19K of bounties and counting)

2/ @joshijoe05 why do you still need the pubspec.yaml of dependencies you getting rid of sir ?

3/ and, could you improve it a bit? such as SignInButton not CustomSignInButton, use a factory to SignInButton.withApple(), SignInButton.withGoogle() :) what do you think.

@joshijoe05
Copy link
Contributor Author

1/ @ibrahimnd2000 @joshijoe05 do you guys want to collaborate with each other to solve this issue. why do i ask ? i see @joshijoe05 has a good idea on getting rid of dependencies and, @ibrahimnd2000 is the first comer. it would be great if you guys can work together to solve this small issue and more importantly, working on next big issues (omi still has $19K of bounties and counting)

2/ @joshijoe05 why do you still need the pubspec.yaml of dependencies you getting rid of sir ?

3/ and, could you improve it a bit? such as SignInButton not CustomSignInButton, use a factory to SignInButton.withApple(), SignInButton.withGoogle() :) what do you think.

Yup!, I have no issue in collaborating with @ibrahimnd2000
Will now work on it and update you, do let me know if any modifications required

@joshijoe05
Copy link
Contributor Author

@mdmohsin7 @beastoin
I have made the requested changes in the code and refactored it, Let me know if any modifications required :)

@beastoin
Copy link
Collaborator

1/ format your code with line length 120 please.
2/ the code looks good, could you drop a demo video ? or a screenshot.

@joshijoe05

@joshijoe05
Copy link
Contributor Author

1/ format your code with line length 120 please. 2/ the code looks good, could you drop a demo video ? or a screenshot.

@joshijoe05

Formatted the code with line length 120 ✅

Here's the working demo

Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-02-14.at.17.53.13.1.1.mp4

@beastoin
Copy link
Collaborator

1/ ✅ ok
2/ ✅ ok
3/ prioritize Sign in with Apple over Sign in with Google and, fix the space between icon - text. 10 on android and 12 on iOS. / ref https://developers.google.com/identity/branding-guidelines, https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple

the last commit pls sir @joshijoe05

@joshijoe05
Copy link
Contributor Author

1/ ✅ ok 2/ ✅ ok 3/ prioritize Sign in with Apple over Sign in with Google and, fix the space between icon - text. 10 on android and 12 on iOS. / ref https://developers.google.com/identity/branding-guidelines, https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple

the last commit pls sir @joshijoe05

3/ done @beastoin
Screenshot 2025-02-15 133858

@ibrahimnd2000
Copy link

1/ ✅ ok 2/ ✅ ok 3/ prioritize Sign in with Apple over Sign in with Google and, fix the space between icon - text. 10 on android and 12 on iOS. / ref https://developers.google.com/identity/branding-guidelines, https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple
the last commit pls sir @joshijoe05

3/ done @beastoin Screenshot 2025-02-15 133858

Screenshot 2025-02-15 at 9 40 29 AM Well you still have alignment issue with icon and text, for which my [PR](https://github.com//pull/1773) was rejected for. 🤷‍♂️

@joshijoe05
Copy link
Contributor Author

joshijoe05 commented Feb 15, 2025

How do you ensure perfect vertical alignment when centering content horizontally, especially with varying text lengths?
If we align them vertically instead of centering horizontally within the button, it may look visually off for different text lengths.
@ibrahimnd2000

Screenshot 2025-02-15 142919

@beastoin beastoin merged commit db9577f into BasedHardware:main Feb 15, 2025
@beastoin
Copy link
Collaborator

lgtm, congratulation @joshijoe05 🚀

please provide deploy plans so that i can push the feature to production, e.g.

  • merge the PR
  • enable google sign in at firebase auth
  • ...
  • deploy app

@beastoin
Copy link
Collaborator

@ibrahimnd2000 man,

his implementation is better than yours.

and, he didn't tell me that there's not much to do just because a library we use doesn't support it yet.

all of above, $80K is waiting for you, guys. keep coding and chasing for the best.

@joshijoe05
Copy link
Contributor Author

lgtm, congratulation @joshijoe05 🚀

please provide deploy plans so that i can push the feature to production, e.g.

  • merge the PR
  • enable google sign in at firebase auth
  • ...
  • deploy app

lgtm, congratulation @joshijoe05 🚀

please provide deploy plans so that i can push the feature to production, e.g.

  • merge the PR
  • enable google sign in at firebase auth
  • ...
  • deploy app

Thank you @beastoin for your guidance throughout! This may be my first PR in OMI, but it’s definitely not my last

Steps to deploy :

  1. Enable Google Sign-In in Firebase Auth
  2. Update GoogleService-Info.plist file with the latest credentials
  3. Verify URL schemes for the reversed client ID match the one in GoogleService-Info.plist
    3.1. Open Runner.xcworkspace in XCode
    3.2. Go to Info Tag and Scroll to bottom
    3.3 Verify reversed google client ID is matching or not otherwise replace it with new one from GoogleService-Info.plist
  4. Test sign-in flow
  5. Deploy the app to production

@joshijoe05
Copy link
Contributor Author

@beastoin
Can you let me know the process to claim the bounty and since this is my first PR merged, how to get free devkit device
https://docs.omi.me/docs/developer/Contribution

@beastoin
Copy link
Collaborator

did you get the bounty via algora ?

anw, man, any ideas on making this more secure, i don't want to put the prod's reverse id to the code haha https://github.com/BasedHardware/omi/pull/1781/files#diff-e6de727143500c0ead434f95d2ab94f82fb8a148da297f2541413b30f5ef2809R52

@joshijoe05

@joshijoe05
Copy link
Contributor Author

did you get the bounty via algora ?

anw, man, any ideas on making this more secure, i don't want to put the prod's reverse id to the code haha https://github.com/BasedHardware/omi/pull/1781/files#diff-e6de727143500c0ead434f95d2ab94f82fb8a148da297f2541413b30f5ef2809R52

@joshijoe05

1/ not received yet, this issue isnt linked with algora, I mailed [email protected] but no response yet. Can you help me how to claim

2/ yes we can do that using preprocessor macros in xcode

@mdmohsin7
Copy link
Collaborator

1/ not received yet, this issue isnt linked with algora, I mailed [email protected] but no response yet. Can you help me how to claim

Replied! Pls check now. It's linked with bountybot.dev, once we have clarity, you'll receive the amount

@beastoin
Copy link
Collaborator

2/ yes we can do that using preprocessor macros in xcode

Could you help with this ? It should link with the current GoogleService-info.plist

@joshijoe05

@joshijoe05
Copy link
Contributor Author

2/ yes we can do that using preprocessor macros in xcode

Could you help with this ? It should link with the current GoogleService-info.plist

@joshijoe05

I have not used them before but the following might help

  1. Create a new configuration settings file in Xcode and add a variable in it
    GOOGLE_CLIENT_ID = google-client-id

  2. Link .xcconfig file in xcode

  3. Reference the variable in info plist file

Refer this : https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project

  • Make sure to mention the config file in gitignore so that you dont push it

@beastoin
Copy link
Collaborator

ScreenRecording_02-16-2025.20-39-35_1.mp4

got crash with Cancel button, can you check it ?

@joshijoe05

@joshijoe05
Copy link
Contributor Author

Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-02-16.at.22.01.29.mp4

It's working fine, can you try again and update me again.
If still there is an issue you can just use try catch block to avoid crash and show user a toast msg.
Let me know how it's going :)

@beastoin
Copy link
Collaborator

crash logs:

--

`8,

Cause: One of IDToken, accessToken, pendingToken, or requestURI must be supplied.

Reported at: 2025-02-16 13:37:33 UTC

Thread 0 Queue 1: com.apple.main-thread (serial):

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 GraphicsServices 0x1ea70d4c0 GSEventRunModal + 163
7 UIKitCore 0x1a010677c -[UIApplication _run] + 815
8 UIKitCore 0x19fd2ce64 UIApplicationMain + 339
9 UIKitCore 0x1a0469a7c keypath_get_selector_hoverStyle + 15923
10 Runner 0x104e85ac0 main (AppDelegate.swift:0)

Thread 1 Unknown:

0 libsystem_pthread.dylib 0x2280f146c start_wqthread + 0

Thread 2 Queue 13: com.apple.root.default-qos (concurrent):

0 libsystem_kernel.dylib 0x1eeb26704 semaphore_wait_trap + 8
1 libdispatch.dylib 0x1a52acbf8 _dispatch_semaphore_wait_slow + 131
2 UIKitCore 0x1a122806c __69+[_UIAsyncInvocationObserver whenInvocationsCompleteForObservers:do:]_block_invoke_2 + 59
3 libdispatch.dylib 0x1a52aa248 _dispatch_call_block_and_release + 31
4 libdispatch.dylib 0x1a52abfa8 _dispatch_client_callout + 19
5 libdispatch.dylib 0x1a52af0f4 _dispatch_queue_override_invoke + 915
6 libdispatch.dylib 0x1a52bdec0 _dispatch_root_queue_drain + 391
7 libdispatch.dylib 0x1a52be6c4 _dispatch_worker_thread2 + 155
8 libsystem_pthread.dylib 0x2280f3644 _pthread_wqthread + 227
9 libsystem_pthread.dylib 0x2280f1474 start_wqthread + 7

Thread 3 com.apple.uikit.eventfetch-thread:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 Foundation 0x19c12ab48 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 211
7 Foundation 0x19c2876f4 -[NSRunLoop(NSRunLoop) runUntilDate:] + 63
8 UIKitCore 0x1a0199b80 -[UIEventFetcher threadMain] + 419
9 Foundation 0x19c216a54 NSThread__start + 723
10 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
11 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 4 io.flutter.1.ui:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 Flutter 0x108816ae0 0x108528000
7 Flutter 0x108816728 0x108528000
8 Flutter 0x108816438 0x108528000
9 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
10 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 5 io.flutter.1.raster:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 Flutter 0x108816ae0 0x108528000
7 Flutter 0x108816728 0x108528000
8 Flutter 0x108816438 0x108528000
9 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
10 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 6 io.flutter.1.io:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 Flutter 0x108816ae0 0x108528000
7 Flutter 0x108816728 0x108528000
8 Flutter 0x108816438 0x108528000
9 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
10 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 7 io.worker.1:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 8 io.worker.2:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 9 io.worker.3:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 10 io.worker.4:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 11 io.worker.5:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 12 io.worker.6:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108580df4 0x108528000
2 Flutter 0x1088104d0 0x108528000
3 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
4 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 13 dart:io EventHandler:

0 libsystem_kernel.dylib 0x1eeb2d4cc kevent + 8
1 Flutter 0x108ad12f0 0x108528000
2 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
3 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 14 Unknown:

0 libsystem_pthread.dylib 0x2280f146c start_wqthread + 0

Thread 15 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 16 com.apple.NSURLConnectionLoader:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 CoreFoundation 0x19d5727f4 __CFRunLoopServiceMachPort + 159
4 CoreFoundation 0x19d571ea0 __CFRunLoopRun + 1211
5 CoreFoundation 0x19d5c4274 CFRunLoopRunSpecific + 587
6 CFNetwork 0x19eae3020 0x19e9f1000
7 Foundation 0x19c216a54 NSThread__start + 723
8 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
9 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 17 Unknown:

0 libsystem_kernel.dylib 0x1eeb26788 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1eeb29db0 mach_msg_overwrite + 423
2 libsystem_kernel.dylib 0x1eeb29bfc mach_msg + 23
3 Instabug 0x107263cbc exception_server_thread + 187
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 18 Unknown:

0 libsystem_kernel.dylib 0x1eeb26510 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x2280f1474 start_wqthread + 7

Thread 19 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 20 Queue 171: com.google.firebase.auth.globalWorkQueue (serial) [Crashed]:

0 CoreFoundation 0x19d5295ec __exceptionPreprocess + 164
1 libobjc.A.dylib 0x19aaa5244 objc_exception_throw + 87
2 CoreFoundation 0x19d6766e0 +[NSException raise:format:] + 127
3 Runner 0x104f4c040 -[FIRVerifyAssertionRequest unencodedHTTPRequestBodyWithError:] (FIRVerifyAssertionRequest.m:160)
4 Runner 0x104f26ca0 -[FIRAuthBackendRPCImplementation callWithRequest:response:callback:] (FIRAuthBackend.m:1195)
5 Runner 0x104f25374 -[FIRAuthBackendRPCImplementation verifyAssertion:callback:] (FIRAuthBackend.m:867)
6 Runner 0x104f24058 +[FIRAuthBackend verifyAssertion:callback:] (FIRAuthBackend.m:623)
7 Runner 0x104f1bb1c -[FIRAuth internalSignInAndRetrieveDataWithCredential:isReauthentication:callback:] (FIRAuth.m:1104)
8 Runner 0x104f1b748 __43-[FIRAuth signInWithCredential:completion:]_block_invoke (FIRAuth.m:983)
9 libdispatch.dylib 0x1a52aa248 _dispatch_call_block_and_release + 31
10 libdispatch.dylib 0x1a52abfa8 _dispatch_client_callout + 19
11 libdispatch.dylib 0x1a52b35cc _dispatch_lane_serial_drain + 767
12 libdispatch.dylib 0x1a52b4124 _dispatch_lane_invoke + 379
13 libdispatch.dylib 0x1a52bf38c _dispatch_root_queue_drain_deferred_wlh + 287
14 libdispatch.dylib 0x1a52bebd8 _dispatch_workloop_worker_thread + 539
15 libsystem_pthread.dylib 0x2280f3680 _pthread_wqthread + 287
16 libsystem_pthread.dylib 0x2280f1474 start_wqthread + 7

Thread 21 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 22 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 23 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 24 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 25 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 26 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 27 Unknown:

0 libsystem_kernel.dylib 0x1eeb26510 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x2280f1474 start_wqthread + 7

Thread 28 Unknown:

0 IBGInvalidFramework 0x104ee4938 0x104edc000

Thread 29 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 30 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 31 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 32 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 33 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 34 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 35 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 36 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 37 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Thread 38 DartWorker:

0 libsystem_kernel.dylib 0x1eeb2c090 __psynch_cvwait + 8
1 Flutter 0x108b9921c 0x108528000
2 Flutter 0x108bd4cac 0x108528000
3 Flutter 0x108b98be8 0x108528000
4 libsystem_pthread.dylib 0x2280f17d0 _pthread_start + 135
5 libsystem_pthread.dylib 0x2280f1480 thread_start + 7

Binary Images:

0x1eeb25000 libsystem_kernel.dylib arm64e E3965DF1-A3A3-374A-94EA-F86739C5CC8E
0x19d4fc000 CoreFoundation arm64e 6A60BE13-E657-3BEC-A9AC-BA239AE29862
0x1ea70c000 GraphicsServices arm64e F4E7A885-F491-3721-862D-C57403F4D821
0x19fd18000 UIKitCore arm64e F80C6EE4-50CA-346F-90EB-BB3DA9817503
0x104e7c000 Runner arm64e 2CF332C7-0B95-39F2-9320-C6135326FFF4
0x2280f0000 libsystem_pthread.dylib arm64e B2FE0DFA-67DE-3D72-8267-6C42073E0E8D
0x1a52a8000 libdispatch.dylib arm64e 8CE3AFB9-6D84-3446-8FD4-E5F798D98403
0x19c101000 Foundation arm64e 7274DDE3-68D6-34A0-8E67-7726E1265E80
0x108528000 Flutter arm64e 4C4C44DC-5555-3144-A1B8-F18F0C0EE878
0x19e9f1000 CFNetwork arm64e 99878792-4064-3260-B5B2-779A99B9F64E
0x106e70000 Instabug arm64e CE7A2469-28FB-38CD-B3EF-817954DA4416
0x19aa74000 libobjc.A.dylib arm64e 3ED8B852-087D-3B6E-A36F-CEAFED8E93AE
0x104edc000 IBGInvalidFramework arm64e 76196B73-F55D-4EBF-AACD-1A02C487499D
`

@joshijoe05
Copy link
Contributor Author

The issue seems to be caused by missing credentials when creating the authentication credential in the signInWithGoogle() method within backend/auth.dart. The crash report states:
Cause: One of IDToken, accessToken, pendingToken, or requestURI must be supplied.

I couldn’t reproduce the error since it’s working fine on my simulator. However, based on the crash report, the issue likely occurs when supplying idToken and accessToken.

Although the method is inside a try-catch block, async operations might bypass it, causing the crash. To prevent this, we should add null checks before creating the credential.

Add explicit if-else checks in signInWithGoogle() to handle missing tokens.

This is how the code looks after adding if else statements :

Future<UserCredential?> signInWithGoogle() async {
  try {
    print('Signing in with Google');
    // Trigger the authentication flow
    final GoogleSignInAccount? googleUser = await GoogleSignIn(scopes: ['profile', 'email']).signIn();
   // added this
    if (googleUser == null) {
      debugPrint('Failed to sign in with Google: $e');
      Logger.handle(e, null, message: 'An error occurred while signing in. Please try again later.');
      return null;
    }
    print('Google User: $googleUser');
    // Obtain the auth details from the request
    final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;
   // added this
    if (googleAuth == null) {
      debugPrint('Failed to sign in with Google: $e');
      Logger.handle(e, null, message: 'An error occurred while signing in. Please try again later.');
      return null;
    }
    print('Google Auth: $googleAuth');

    // Create a new credential
    // TODO: store email + name, need to?
    final credential = GoogleAuthProvider.credential(
      accessToken: googleAuth?.accessToken,
      idToken: googleAuth?.idToken,
    );

    // Once signed in, return the UserCredential
    var result = await FirebaseAuth.instance.signInWithCredential(credential);
    var givenName = result.additionalUserInfo?.profile?['given_name'] ?? '';
    var familyName = result.additionalUserInfo?.profile?['family_name'] ?? '';
    var email = result.additionalUserInfo?.profile?['email'] ?? '';
    if (email != null) SharedPreferencesUtil().email = email;
    if (givenName != null) {
      SharedPreferencesUtil().givenName = givenName;
      SharedPreferencesUtil().familyName = familyName;
    }
    // TODO: test subsequent signIn
    debugPrint('signInWithGoogle Email: ${SharedPreferencesUtil().email}');
    debugPrint('signInWithGoogle Name: ${SharedPreferencesUtil().givenName}');
    return result;
  } catch (e) {
    debugPrint('Failed to sign in with Google: $e');
    Logger.handle(e, null, message: 'An error occurred while signing in. Please try again later.');
    return null;
  }
}

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

Successfully merging this pull request may close these issues.

Sign in with Google/appple
4 participants