Login with AppleID Question...

So I am using ParseUI to login with AppleID. Everything works great, except I cannot seem to get the email address. I have looked at the Poarse code and it seems to be requesting it. I also see the box checked in the login dialog apple provides when I perform the login.

However, the PFUser Object shows the email as nil. It does populate username.

Here is some code:

extension OnboardViewController: PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate
{
	// LogInViewController Delegate Methods
	@available(iOS 13.0, *)
	func log(_ logInController: PFLogInViewController, didReceiveAppleCredential credential: ASAuthorizationAppleIDCredential, for user: PFUser)
	{
		print("didReceiveAppleCredential")
	}

	func log(_ logInController: PFLogInViewController, didLogIn user: PFUser)
	{
		print("didLogIn")
		if #available(iOS 13.0, *)
		{
			let storyboard = UIStoryboard(name: "Main", bundle: nil)
			let mainTabBarController = storyboard.instantiateViewController(identifier: "MainTabBarController")

			// This is to get the SceneDelegate object from your view controller then call the change root view controller function to change to main tab bar
			(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.changeRootViewController(mainTabBarController)
		}
		else
		{
			// Fallback on earlier versions
			print("Earlier Vers")
			(UIApplication.shared.delegate as! AppDelegate).switchRootViewToHome()
		}
	}
}

If I set a breakpoint at either of the functions above and check the PFUser username and email, the email always show nil. The user name is populated and the user DB shows the same.

Is there something special I need to do to get the email address?

As mentioned here:

You are not categorizing your question for the right SDK, you are using the iOS SDK not the Swift SDK. If you ever are using something that begins with PF... you are using the iOS SDK, that’s not used at all in the Swift SDK.

In addition, your question has been answered: Login with AppleID Question... · Issue #1624 · parse-community/Parse-SDK-iOS-OSX · GitHub

I recommend reading the Apple documentation for Apple Login and other threads as this is mentioned:

This behaves correctly, user info is only sent in the ASAuthorizationAppleIDCredential upon initial user sign up. Subsequent logins to your app using Sign In with Apple with the same account do not share any user info and will only return a user identifier in the ASAuthorizationAppleIDCredential. It is recommened that you securely cache the initial ASAuthorizationAppleIDCredential containing the user info until you can validate that an account has succesfully been created on your server.

@cbaker6 Yes, thank you. I understand the first time issue. And I can reset that by deleting the app from the applied apple, site. In any case, so far, I have not been able to get the email. However, you said some things that may help and point me to the solution… thanks you!!

I will look at the swift sdk, I would prefer that if it is the same or improved from the objc sdk. What does the swift sdk prefix with if they do not use PF? I will check it out. Thank you so much for the help.

@cbaker6 So currently I am using these three:

pod ‘Parse’
pod ‘ParseLiveQuery’
pod ‘Parse/UI’

I assume to use the Swift SDK I still need Parse, but it looks like the Swift SDK includes LiveQuery, but I was unsure about Parse/UI. The particular project I am on know uses the parse ui.

  1. So what sdk’s do I need to use?
  2. If UI is not included with the Swift SDK can I still use Parse/UI?

I do not really need the UI, because we just use Email and Apple Login and it is simple enough to implement I suppose. And sign up is our own anyway.

Yes, you are correct, ParseSwift doesn’t have ParseUI, so you will have to do something different there.

I do not really need the UI, because we just use Email and Apple Login and it is simple enough to implement I suppose. And sign up is our own anyway.

The Swift SDK can work easily with SwiftUI or UIKit. You will not be able to use ParseUI from the Objc SDK with the Swift SDK, they are not compatible. More details listed here:

The Swift SDK also uses Swift Package Manager (SPM), though it can be installed via Cocoapods, I recommend going away from it as the SDK is much easier to manage with SPM.

The Swift Playgrounds should help tremendously since you are already familiar with the iOS SDK:

You can fire up this docker image which is configured to work with Playgrounds out-of-the-box and test out different ways of using the Swift SDK in Playgrounds and see the differences.

In addition, you can look through the sample app I created which is similar to AnyPic from the original Parse, but using SwiftUI and ParseSwift:

Another sample app I created that uses the Swift SDK is a medical based app:

Feel free to fork and start creating your app from there if it helps!

Awesome, you have been most helpful. I am checking it all out now. Thank you so much for taking the time to help. Have a great day!!

1 Like