How to integrate sign in with apple in iOS 12 or earlier? [duplicate]

主宰稳场 提交于 2020-12-31 02:40:26

问题


My app was rejected due to a third-party login service. So I've implemented Sign in with Apple for iOS 13. Problem is how to provide backward compatibility for iOS 12 or earlier.


回答1:


In my case, it only works (for iOS12 and below) if I avoid importing CryptoKit for the sha256 encryption. Instead of using the sha256 function provided by CryptoKit you can extend the String class adding a sha256 function by importing CommonCrypto.

You can check the code in my answer here: https://stackoverflow.com/a/60987888/2025766

Importing CryptoKit on iOS12 and below will crash your app with this error:

Library not loaded: /System/Library/Frameworks/CryptoKit.framework/CryptoKit"

when the app starts.

I also tried to use #if canImport(CryptoKit) for conditional import and set -weak_framework CryptoKit in Other Linker Flags but still crashing for iOS12. So far avoid CryptoKit is the only solution that I found.




回答2:


Add -weak_framework Cryptokit in Other Linker Flags of respective target's build settings.




回答3:


Check apple official page here. You need to go out and open a webpage and then comeback to the application with error (user cancel) or success with the scope you've requested.




回答4:


Apple nowadays recommends it's Sign in with Apple JS in combination with their REST API.

You basically create an own button that uses the Apple Marketing resource images and then call their REST API to initiate the authorization flow. For the initial log-in window, you can use a WKWebView and handle the callback URL via the successful / failed redirect.



来源:https://stackoverflow.com/questions/60862840/how-to-integrate-sign-in-with-apple-in-ios-12-or-earlier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!