invertase / react-native-apple-authentication

A React Native library providing support for Apple Authentication on iOS and Android.
Other
1.36k stars 215 forks source link

Additional config for release is needed? #302

Closed carlosen14 closed 1 year ago

carlosen14 commented 1 year ago

Hi. I was already using this, but after upgrading from RN 63 to 66, it stopped working. I upgraded this lib to latest version, but now only works on debug, not on release. On debug i can login, it retrieves the email, all fine, also works fine if user cancel apple login. On release, when tap, it does nothing. I use it with hooks.

I reviewed the INITIAL_SETUP, FIREBASE, and the README.

What I didn't found was, the version relations to make it work, like the combination for which invertase library version goes with which RN version. I don't know if I should upgrade RN to 0.70.2 (latest). any hint?

RN 0.66.3 Xcode 14.0.1 IOS DEVELOPMENT VERSION 13 @invertase/react-native-apple-authentication 2.2.2

Applied the fixes for RCT-Folly / Time.h, on Podfile

# FIX rct-folly __IPHONE_10_0
`sed -i -e  $'s/__IPHONE_10_0/__IPHONE_14_0/' ios/Pods/RCT-Folly/folly/portability/Time.h`
# FIX rct-folly / time.h typedef redefinition
`sed -i -e  $'s/typedef uint8_t clockid_t;//' ios/Pods/RCT-Folly/folly/portability/Time.h`
mikehardy commented 1 year ago

In general, always use latest all things prior to attempting to troubleshoot further For instance the sed you are using is something I originally proposed way back when, and is no longer needed in modern react-native-versions iOS 16 simulators work fine now (finally), no need to stay on ios13

I just tested my work app in production and it appeared to work fine for me, as a release mode install

carlosen14 commented 1 year ago

ok, so you said I should upgrade all versions, but, you mean to upgrade RN? or also these?, i am using version 11.2.0 react-native-firebase, but i see there is version 15.7.0.

    "@react-native-firebase/analytics": "^11.2.0",
    "@react-native-firebase/app": "^11.2.0",
    "@react-native-firebase/auth": "^11.2.0",
    "@react-native-firebase/dynamic-links": "^11.2.0",
    "@react-native-firebase/firestore": "^11.2.0",
    "@react-native-firebase/messaging": "^11.2.0",
    "@react-native-firebase/storage": "^11.2.0",
mikehardy commented 1 year ago

If you are having a problem, and you are on outdated versions, it's highly unlikely any maintainer of any software will want to investigate until the software versions are up to date, that is all of them that are involved as you attempt a minimal reproduction (https://stackoverflow.com/help/minimal-reproducible-example) - because we release software updates to fix bugs and if you're not on the current versions a) it's likely it's already fixed b) even if we fix it you can't get the fix until you update so...

You should update.

And yes, I mean react-native, react-native-firebase, this package, yes. It's a pain but updating dependencies is a regular maintenance task and should be performed regularly, or at least before logging an issue

I'll repeat that I do not reproduce this, it's working for me in release mode.

carlosen14 commented 1 year ago

It's okei, thanks for your help, i just was asking for a hint because I've ended my options and read most of this repo issues, I've read your previous comment where you ask for a minimal example, but i wasn't asking for an answer 😄. Actually I don't like ask for help, but here I am desperate..

carlosen14 commented 1 year ago

I am sorry I came back.. I couldn't solve it yet.

I updated RN and this lib versions, and it seems to now throw an ERROR 1000 which only happens on Release mode when running from TestFlight, when running locally on Release or Debug works fine (device and simulator)..

(I know it is a super generic errcode, i saw a lot of issues about them), but wanted to know if there is another hint, I got all the same (code, certs, config, keys, etc.), also I know this is not related to firebase because the error happens before that auth call, also I know it because installed Sentry to see the log and stack on TestFlight version..

This is my info, hope I can get a bit of help or hint, pls!.


System:
    OS: macOS 12.6
    CPU: (8) x64 Apple M1
    Memory: 48.13 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK:
      API Levels: 27, 28, 29, 30, 31, 32
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-30 | Google Play Intel x86 Atom, android-S | Google APIs ARM 64 v8a, android-S | Google Play ARM 64 v8a
      Android NDK: 23.0.7344513-beta4
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7935034
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.2 => 17.0.2 
    react-native: ^0.68.3 => 0.68.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

This is the pacakge.json dependencies part

  "dependencies": {
    "@invertase/react-native-apple-authentication": "^2.1.2",
    "@react-native-firebase/analytics": "^14.12.0",
    "@react-native-firebase/app": "^14.12.0",
    "@react-native-firebase/auth": "^14.12.0",
    "@react-native-firebase/dynamic-links": "^14.12.0",
    "@react-native-firebase/firestore": "^14.12.0",
    "@react-native-firebase/messaging": "^14.12.0",
    "@react-native-firebase/storage": "^14.12.0",
    "@react-native-google-signin/google-signin": "^6.0.0",
    "@react-native-twitter-signin/twitter-signin": "^1.2.0",
    // delete unrelated
  },
  "devDependencies": {
    "@babel/core": "7.13.10",
    "@babel/runtime": "7.13.10",
    "@react-native-community/eslint-config": "1.1.0",
    "@types/react-native-dotenv": "^0.2.0",
    "babel-jest": "25.5.1",
    "eslint": "^7.32.0",
    "jest": "25.5.4",
    "metro-react-native-babel-preset": "^0.72.3",
    "react-native-version": "^4.0.0",
    "react-test-renderer": "16.13.1"
  },

From code, there isn't any difference Custom button

image

Button onPress function

image

AppleSignIn (this lib func)

image

On Xcode, AppleSignIn is enabled (obviously but had to make it clear) image

Add this to Xcode, automatically modifies the Entitlement file, adding the key "com.apple.developer.applesignin", which is already on "Default" value

From Apple Developer console

On identifiers image

It is set as primaryID image

Without a Server to Server Notification Endpoint (I didn't saw that as mandatory), also tested with the value Firebase is giving us (https://.firebaseapp.com/__/auth/handler) image

added the email address, on service image

Created the key, with AppleSignIn service enabled image

Just in case, set the key-values on firebase image

carlosen14 commented 1 year ago

@mikehardy i have a doubt about grouping service keys.. the initial guide mention that

Please note: If you choose another app to be your primary app, you will have to go through the above noted process, up until you navigate to the Apple developer console, and choose the Group with existing primary App ID option & the testAppleButton ID.

And I see the Apple Dev Team account i belong, has other 2 "Enable as primary App ID" Identifiers, might this interfere?, each one has their own key anyway.

image
carlosen14 commented 1 year ago

I updated to set my app as group, from another primary App ID, and this appears.

image

if we are just signing with automatic mode from Xcode. Doesn't affect, right?

carlosen14 commented 1 year ago

I guess I have to keep them separated as primary App ID, because each one app bundle was registered on different firebase instance project (and is already configured)

carlosen14 commented 1 year ago

You know what? just for the record, it was a cert issue, al this time I was archiving and uploading using fastlane with automatic signing, then i tried just archive and upload using xcode (all same code, version, pods, etc) and it worked (i double check this!!!!)

thanks for your help, you're a great guy, i've seen you in other RN firebase repos 😄

mikehardy commented 1 year ago

Apple signing is a real pain isn't it?

I have a couple fastlane chunks that rebuild certs, one "nicely" (just checks if they are in sync) and one with the "force" option (blows local state away and pulls from my signing cert repo down to local machine).

It's part of a generic "convergence" script I run on development and build machines called "doctor.sh" that brings versions up to date, checks for the right packages and stuff, and it's basically the first thing I run when I have a mysterious problem

None of that information is a direct solution to your problem, but there are so many things that can go wrong in mobile development, scripting a "check local state + install all packages needed for local development + clean local caches and certs and stuff + re-install everything and do a test build for all architectures" is a strategy that gives a pretty solid base to develop on. And gives enough time for a coffee break when you run it ;-)

Cheers