Coder Social home page Coder Social logo

Comments (9)

tp avatar tp commented on August 17, 2024

Sorry, I don't have any experience with this kind of Sign in with Apple -> Firebase integration.

The common behavior with this plug-in people stumble upon is that the name is only provided for the initial sign-up (let's call it registration), and must then be stored in ones own data storage.
From previous experience I know that the "default" Firebase SiwA integration does indeed save the user's name on their user object. Is it possible that you had different code running on the first login (= registration)? If so, try disassociating your Apple ID from the app and register anew.

from dart_packages.

ahsanfarooq6414 avatar ahsanfarooq6414 commented on August 17, 2024

Sorry, I don't have any experience with this kind of Sign in with Apple -> Firebase integration.

The common behavior with this plug-in people stumble upon is that the name is only provided for the initial sign-up (let's call it registration), and must then be stored in ones own data storage. From previous experience I know that the "default" Firebase SiwA integration does indeed save the user's name on their user object. Is it possible that you had different code running on the first login (= registration)? If so, try disassociating your Apple ID from the app and register anew.

No I am not using any other code for registering the user.

from dart_packages.

ElvistLui avatar ElvistLui commented on August 17, 2024

It may be a Firebase's problem. I used FirebaseAuth before and was unable to obtain the user's email address, whether it was real or anonymous. I gave feedback to Firebase, and they replied that they are currently investigating the issue

from dart_packages.

ahsanfarooq6414 avatar ahsanfarooq6414 commented on August 17, 2024

It may be a Firebase's problem. I used FirebaseAuth before and was unable to obtain the user's email address, whether it was real or anonymous. I gave feedback to Firebase, and they replied that they are currently investigating the issue

please let me know if you find any solution regarding this issue thanks.

from dart_packages.

hajiboy95 avatar hajiboy95 commented on August 17, 2024

Same problem here.
I use the following the snippets

final AppleAuthProvider appleProvider = AppleAuthProvider().addScope('name'); cred = await FirebaseAuth.instance.signInWithProvider(appleProvider);

and

`try {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.fullName,
AppleIDAuthorizationScopes.email
],
);

// Create an OAuthCredential from the credential returned by Apple.
final oauthCredential = OAuthProvider("apple.com").credential(
idToken: appleCredential.identityToken,
);
final UserCredential cred =
await FirebaseAuth.instance.signInWithCredential(oauthCredential);

  if (cred.user?.displayName == null ||
      (cred.user?.displayName != null && cred.user!.displayName!.isEmpty)) {
    final fixDisplayNameFromApple = [
      appleCredential.givenName ?? '',
      appleCredential.familyName ?? '',
    ].join(' ').trim();
    await cred.user?.updateDisplayName(fixDisplayNameFromApple);
  }`

For both of them i don't get any "name" or "email" (email only requested in the second though).
Already read, that it is only send at the first login attempt. Deleted userdata from DB, followed this instruction and nothing seems to work...

Very frustrating, my app gets declined by apple due to this..

Contacted Firebase and Apple support asking for help. If I'll find a solution i let you guys know.

Another problem seems to be that i don't even get shown this form

image

For me it looks always like this

2024-05-21 12 38 06

Not been asked for any email or name, anybody know why it is like that?

from dart_packages.

hajiboy95 avatar hajiboy95 commented on August 17, 2024

In the end, this seemed to work for me

if (cred.user?.displayName == null || (cred.user?.displayName != null && cred.user!.displayName!.isEmpty)) { final fixDisplayNameFromApple = [ appleCredential.givenName ?? '', appleCredential.familyName ?? '', ].join(' ').trim(); await cred.user?.updateDisplayName(fixDisplayNameFromApple); }

seems like it doesn't work on ios 17.5 however though. 17.4 and lower is working

from dart_packages.

HassanrazaBhatti avatar HassanrazaBhatti commented on August 17, 2024

@hajiboy95 some people have reported that on different other platforms that App Store is rejection applications with this solution can someone please confirm this ? and also can u send me complete code how are u managing first time sign in and second sign in in this case ?

from dart_packages.

hajiboy95 avatar hajiboy95 commented on August 17, 2024

So in the end it worked quite easy for me. Now I have:

Future<void> signInWithApple() async {
    try {
      final AppleAuthProvider appleProvider =
          AppleAuthProvider().addScope('name');
      cred = await FirebaseAuth.instance.signInWithProvider(appleProvider);
      await getUserData();
    } catch (error) {
      SnackBar(content: Text('Error signing in with Apple: $error'));
      debugPrint('Error signing in with Apple: $error');
      // Handle the error as needed in your application
    }
  }

where the getUserData() method is

Future<void> getUserData() async {
    if (currentUser != null) {
      uData = await userDataRepository().getByID(currentUser!.uid);
      uData ??= userData(
          id: currentUser!.uid,
          name: cred?.user?.displayName,
          profile_picture_url: cred?.user?.photoURL,
          creation_date: cred?.user?.metadata.creationTime);
    } else {
      uData = null;
    }
  }

later on i use the uData for filling in the form.
If apple complains i guess i'll just write a mail to them. so far it worked a few times to hand in my app (i didn't launched it yet, still in testing. but just sendet it a few times to apple to see whether they'll accept my method or not)

from dart_packages.

askankit avatar askankit commented on August 17, 2024

I was facing the same problem with FirebaseAuth. The displayName was always null here is how you can fix it.

Future<UserModel?> _signInWithCredential(OAuthCredential oauthCredential, {String? userName, String? email, required String socialType}) async {
    try {
      final userCredential = await FirebaseAuth.instance.signInWithCredential(oauthCredential);
      final authUser = userCredential.user;
      if (authUser != null) {
        await authUser.updateProfile(displayName: userName,);
        await authUser.reload();
        final updatedUser = FirebaseAuth.instance.currentUser;
        return UserModel(
          social_id: updatedUser?.uid ?? authUser.uid,
          email: email ?? authUser.email,
          socialType: socialType,
          deviceToken: "No Device Token",
          name: updatedUser?.displayName ?? userName,
        );
      }else{
        return null;
      }
    } catch (e, s) {
      blocLog(msg: 'Sign-in with credential error: $e', bloc: "AuthServices", exp: s.toString());
      return null;
    }
  }

from dart_packages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.