我目前处于 Debug模式并在我的设备上运行我的应用。
我正在使用 sign_in_with apple 和这段代码
Future<FirebaseUser> signInWithApple() async {
var redirectURL = "https://SERVER_AS_PER_THE_DOCS.glitch.me/callbacks/sign_in_with_apple";
var clientID = "AS_PER_THE_DOCS";
final appleIdCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: clientID,
redirectUri: Uri.parse(
redirectURL)));
final oAuthProvider = OAuthProvider(providerId: 'apple.com');
final credential = oAuthProvider.getCredential(
idToken: appleIdCredential.identityToken,
accessToken: appleIdCredential.authorizationCode,
);
final authResult =
await SignInUtil.firebaseAuth.signInWithCredential(credential);
return authResult.user; }
但在我登录 chrome 后,它会重定向到我在 Playstore 上的应用程序,当我尝试打开该应用程序时,日志显示:
E/flutter (19796): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: SignInWithAppleAuthorizationError(AuthorizationErrorCode.canceled, The user closed the Custom Tab)
E/flutter (19796): #0 SignInWithApple._signInWithAppleAndroid (package:sign_in_with_apple/src/sign_in_with_apple.dart:239:7)
E/flutter (19796): <asynchronous suspension>
我是否遗漏了一些我忘记添加的内容?
最佳答案
我发现了错误。原来是忘记加了
<activity
android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="signinwithapple" />
<data android:path="callback" />
</intent-filter>
</activity>
在我的 AndroidManifest.xml 文件中
关于ios - 苹果登录使用安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70960400/