title: IOS Sign In with apple using swift crashes on iPad only on apple review
body: <p>My webview app was rejected because I don't have <code>apple sign in</code>, so I implemented it and tested it before submitting, I got rejected again that it crashed on <code>iPad running iOS 13.6.1 on WiFi </code> when clicked on sign in with apple. I have tested in almost with all iPad in emulator but it seems to work very fine. Please can someone help me out, am really new in iOS, can't even understand the error logs they included.</p>
  <p>Bellow I have included every related class I used for my apple sign in and also a link to error log report <a href="https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple114/v4/d9/bf/6d/d9bf6da7-c917-8c69-88fd-e7433f22754e/attachment.crashlog-9732D4B5-498A-4122-A6B0-AF9CB1F83B1D.txt?accessKey=1597665839_5425227659922579947_K0VvPf4VJDZztv4XIVHpCvTVMTUDmvvl9X0SxJAERXYIIcrXw1ccp8Cuy7TW0hlcSgIEoVF90OdGNbghJ%2Bj3NBcACY3EmjSrI2mlhkK88YBJZhXQcw591pMcq%2FdFRTzqifnfqi5i6fn1og7edukxXfXtKJv827kS7c%2BFAH9nKi%2BRMSGAmJQ2kq%2FxvrJWB1ScrX4RVWu127F%2BYh%2Fhie92h7%2BF01j5uTaomn0kmUWerhY%3D" rel="nofollow noreferrer">ERROR REPORT 1</a> and <a href="https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple114/v4/42/93/57/4293575f-b859-cd20-572c-74eb8d7b1bc8/attachment.crashlog-E2ADFB36-E4D3-469D-AA2C-E56DFDE8AD57.txt?accessKey=1597665839_1225071962648304460_OqUx%2B73X7ZVxyHQKRONl%2F7APl1bKTnv4%2BDx6lvyqUEI6j1D8EKTWJ4hvyx981x%2F5f7TMxGGhtxqmi%2Bh0yuiu37yGiL6bLHgTonNIi3M9yO6WvSduZIzeR2cHAKXw7wIBo0NYwvG9mnushXvo0eYiNqRSom1FrpYfu5UEZoQIRbs8pNOLqUlutwn46hEQXAzUzweezQOdQaekToZLyqos37iScp0kFEm7aQx9qiV9TsM%3D" rel="nofollow noreferrer">ERROR REPORT 2</a>.</p>
  <p>My main view controller</p>
  <pre><code>class HomeVC: UIViewController {
      func signInWithAppleButtonPressed() {
          let provider = ASAuthorizationAppleIDProvider()
          let request = provider.createRequest()
          request.requestedScopes = [.fullName, .email]
  
          let controller = ASAuthorizationController(authorizationRequests: [request])
          controller.presentationContextProvider = self
          controller.delegate = self
          controller.performRequests()
      }
  
      //I call this method on javascript callback from webview
      //signInWithAppleButtonPressed()
  }
  </code></pre>
  <p>Extension for apple login</p>
  <pre><code>extension HomeVC: ASAuthorizationControllerDelegate {
  
    func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
          guard let credentials = authorization.credential as? ASAuthorizationAppleIDCredential else {return}
          
      var payload: [String: Any] = [:]
      if user.apple_payload.count &gt; 0 &amp;&amp; user.apple_payload[&quot;id&quot;] as! String == credentials.user {
          payload = user.apple_payload
      }else {
          payload = [
              &quot;givenName&quot;: credentials.fullName?.givenName as Any,
              &quot;familyName&quot;: credentials.fullName?.familyName as Any,
              &quot;email&quot;: credentials.email as Any,
              &quot;id&quot;: credentials.user
          ]
           user.apple_payload = payload
      }
  
        if let identifyToken = credentials.identityToken {
           if let token = String(bytes: identifyToken, encoding: .utf8) {
               user.apple_id = credentials.user
               payload[&quot;identityToken&quot;] = token
              let str = Utils.shared.DictionaryToString(payload: payload)
              if !str.isEmpty {
                  SendToBackEnd(Utils.shared.toBase64(str: str))
              }
           }
           return
        }
  
    }
    
    func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
      print(&quot;Authorization returned an error: \(error.localizedDescription)&quot;)
    }
  }
  
  
  extension HomeVC: ASAuthorizationControllerPresentationContextProviding {
  
    func presentationAnchor(for controller: ASAuthorizationController) -&gt; ASPresentationAnchor {
      return view.window!
    }
  }
  </code></pre>
  <p>My Utils Class</p>
  <pre><code>class Utils {
      static let shared = Utils()
      func DictionaryToString(payload: [String: Any]) -&gt; String {
          if let jsonData = try? JSONSerialization.data(withJSONObject: payload, options: []) {
              if let jsonString = String(data: jsonData, encoding: .utf8) {
                  return jsonString
              }
          }
          return &quot;&quot;
      }
      func toBase64(str: String) -&gt; String {
          let utf8str = str.data(using: .utf8)
          if let base64Encoded = utf8str?.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) {
          return base64Encoded
          }
          return &quot;&quot;
      }
  }
  </code></pre>
  <p>My User Class</p>
  <pre><code>class User {
  
      var apple_id: String {
          get {
              return UserDefaults.standard.string(forKey: &quot;UserAppleIdentification&quot;) ?? &quot;&quot;
          }
          set {
              UserDefaults.standard.set(newValue, forKey: &quot;UserAppleIdentification&quot;)
              UserDefaults.standard.synchronize()
          }
      }
      
      var apple_payload: [String: Any] {
          get {
              return (UserDefaults.standard.dictionary(forKey: &quot;UserApplePayloadIdentification&quot;) ?? [:]) as [String: Any]
          }
          set {
              UserDefaults.standard.set(newValue, forKey: &quot;UserApplePayloadIdentification&quot;)
              UserDefaults.standard.synchronize()
          }
      }
  }
  </code></pre>