feat: Implement Apple Sign-In for Android by adding a callback function, updating redirect URI, and configuring the Android manifest.
This commit is contained in:
@@ -40,6 +40,20 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Apple Sign In Callback Activity -->
|
||||
<activity
|
||||
android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop">
|
||||
<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="/" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
|
||||
@@ -144,3 +144,22 @@ exports.onExpenseCreated = functions.firestore
|
||||
{ groupId: groupId }
|
||||
);
|
||||
});
|
||||
|
||||
exports.callbacks_signInWithApple = functions.https.onRequest((req, res) => {
|
||||
const code = req.body.code;
|
||||
const state = req.body.state;
|
||||
const id_token = req.body.id_token;
|
||||
const user = req.body.user;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
if (code) params.append('code', code);
|
||||
if (state) params.append('state', state);
|
||||
if (id_token) params.append('id_token', id_token);
|
||||
if (user) params.append('user', user);
|
||||
|
||||
const qs = params.toString();
|
||||
const packageName = 'be.devdayronvl.travel_mate';
|
||||
const redirectUrl = `intent://callback?${qs}#Intent;package=${packageName};scheme=signinwithapple;end`;
|
||||
|
||||
res.redirect(302, redirectUrl);
|
||||
});
|
||||
|
||||
@@ -58,6 +58,9 @@ class _LoadingContentState extends State<LoadingContent>
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Erreur lors de la tâche en arrière-plan: $e');
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,20 +225,20 @@ class AuthService {
|
||||
}
|
||||
|
||||
// Request Apple ID credential with platform-specific configuration
|
||||
final AuthorizationCredentialAppleID credential =
|
||||
await SignInWithApple.getAppleIDCredential(
|
||||
scopes: [
|
||||
AppleIDAuthorizationScopes.email,
|
||||
AppleIDAuthorizationScopes.fullName,
|
||||
],
|
||||
// Configuration for Android/Web
|
||||
webAuthenticationOptions: WebAuthenticationOptions(
|
||||
clientId: 'be.devdayronvl.travel_mate.service',
|
||||
redirectUri: Uri.parse(
|
||||
'https://travelmate-a47f5.firebaseapp.com/__/auth/handler',
|
||||
),
|
||||
),
|
||||
);
|
||||
final AuthorizationCredentialAppleID
|
||||
credential = await SignInWithApple.getAppleIDCredential(
|
||||
scopes: [
|
||||
AppleIDAuthorizationScopes.email,
|
||||
AppleIDAuthorizationScopes.fullName,
|
||||
],
|
||||
// Configuration for Android/Web
|
||||
webAuthenticationOptions: WebAuthenticationOptions(
|
||||
clientId: 'be.devdayronvl.TravelMate.service',
|
||||
redirectUri: Uri.parse(
|
||||
'https://us-central1-travelmate-a47f5.cloudfunctions.net/callbacks_signInWithApple',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Create OAuth credential for Firebase
|
||||
final OAuthCredential oauthCredential = OAuthProvider("apple.com")
|
||||
|
||||
Reference in New Issue
Block a user