@@ -32,6 +32,7 @@ public class PassportManager : MonoBehaviour
3232 [ SerializeField ] private bool autoInitialize = true ;
3333 [ SerializeField ] private bool autoLogin = false ;
3434 [ SerializeField ] private DirectLoginMethod directLoginMethod = DirectLoginMethod . None ;
35+ [ SerializeField ] private MarketingConsentStatus defaultMarketingConsent = MarketingConsentStatus . Unsubscribed ;
3536 [ SerializeField ] private LogLevel logLevel = LogLevel . Info ;
3637 [ SerializeField ] private bool redactTokensInLogs = true ;
3738
@@ -206,19 +207,19 @@ public async void Login()
206207 }
207208
208209 /// <summary>
209- /// Login with a specific direct login method
210+ /// Login with custom direct login options
210211 /// </summary>
211- /// <param name="loginMethod">The login method to use (Google, Apple, Facebook, or None for default) </param>
212- public async void Login ( DirectLoginMethod loginMethod )
212+ /// <param name="directLoginOptions">Custom direct login options including method, email, and marketing consent </param>
213+ public async void Login ( DirectLoginOptions directLoginOptions )
213214 {
214- await LoginAsync ( loginMethod ) ;
215+ await LoginAsync ( directLoginOptions : directLoginOptions ) ;
215216 }
216217
217218 /// <summary>
218219 /// Internal async login method
219220 /// </summary>
220- /// <param name="loginMethod ">Optional login method override . If not provided , uses the configured directLoginMethod</param>
221- private async UniTask LoginAsync ( DirectLoginMethod ? loginMethod = null )
221+ /// <param name="directLoginOptions ">Optional direct login options . If null , uses the configured directLoginMethod</param>
222+ private async UniTask LoginAsync ( DirectLoginOptions directLoginOptions = null )
222223 {
223224 if ( ! IsInitialized || PassportInstance == null )
224225 {
@@ -228,13 +229,44 @@ private async UniTask LoginAsync(DirectLoginMethod? loginMethod = null)
228229
229230 try
230231 {
231- DirectLoginMethod methodToUse = loginMethod ?? directLoginMethod ;
232- string loginMethodText = methodToUse == DirectLoginMethod . None
233- ? "default method"
234- : methodToUse . ToString ( ) ;
232+ // Determine final DirectLoginOptions to use
233+ DirectLoginOptions finalDirectLoginOptions ;
234+ string loginMethodText ;
235+
236+ if ( directLoginOptions != null )
237+ {
238+ // Use provided DirectLoginOptions (marketing consent already set by developer)
239+ finalDirectLoginOptions = directLoginOptions ;
240+ loginMethodText = directLoginOptions . directLoginMethod . ToString ( ) ;
241+ }
242+ else
243+ {
244+ // Use configured directLoginMethod from Inspector
245+ loginMethodText = directLoginMethod == DirectLoginMethod . None
246+ ? "default method"
247+ : directLoginMethod . ToString ( ) ;
248+
249+ if ( directLoginMethod == DirectLoginMethod . None )
250+ {
251+ // Standard auth flow
252+ finalDirectLoginOptions = null ;
253+ }
254+ else
255+ {
256+ // Direct login with configured default marketing consent
257+ finalDirectLoginOptions = new DirectLoginOptions ( directLoginMethod , marketingConsentStatus : defaultMarketingConsent ) ;
258+ }
259+ }
260+
235261 Debug . Log ( $ "[PassportManager] Attempting login with { loginMethodText } ...") ;
236262
237- bool loginSuccess = await PassportInstance . Login ( useCachedSession : false , directLoginMethod : methodToUse ) ;
263+ // Debug log marketing consent if present
264+ if ( finalDirectLoginOptions ? . marketingConsentStatus != null )
265+ {
266+ Debug . Log ( $ "[PassportManager] Marketing consent: { finalDirectLoginOptions . marketingConsentStatus } ") ;
267+ }
268+
269+ bool loginSuccess = await PassportInstance . Login ( useCachedSession : false , directLoginOptions : finalDirectLoginOptions ) ;
238270 if ( loginSuccess )
239271 {
240272 IsLoggedIn = true ;
@@ -324,23 +356,23 @@ private void ConfigureUIElements()
324356 if ( googleLoginButton != null )
325357 {
326358 googleLoginButton . onClick . RemoveAllListeners ( ) ;
327- googleLoginButton . onClick . AddListener ( ( ) => Login ( DirectLoginMethod . Google ) ) ;
359+ googleLoginButton . onClick . AddListener ( ( ) => Login ( new DirectLoginOptions ( DirectLoginMethod . Google , marketingConsentStatus : defaultMarketingConsent ) ) ) ;
328360 googleLoginButton . interactable = IsInitialized && ! IsLoggedIn ;
329- Debug . Log ( "[PassportManager] Configured Google login button" ) ;
361+ Debug . Log ( $ "[PassportManager] Configured Google login button with defaultMarketingConsent: { defaultMarketingConsent } ") ;
330362 }
331363
332364 if ( appleLoginButton != null )
333365 {
334366 appleLoginButton . onClick . RemoveAllListeners ( ) ;
335- appleLoginButton . onClick . AddListener ( ( ) => Login ( DirectLoginMethod . Apple ) ) ;
367+ appleLoginButton . onClick . AddListener ( ( ) => Login ( new DirectLoginOptions ( DirectLoginMethod . Apple , marketingConsentStatus : defaultMarketingConsent ) ) ) ;
336368 appleLoginButton . interactable = IsInitialized && ! IsLoggedIn ;
337369 Debug . Log ( "[PassportManager] Configured Apple login button" ) ;
338370 }
339371
340372 if ( facebookLoginButton != null )
341373 {
342374 facebookLoginButton . onClick . RemoveAllListeners ( ) ;
343- facebookLoginButton . onClick . AddListener ( ( ) => Login ( DirectLoginMethod . Facebook ) ) ;
375+ facebookLoginButton . onClick . AddListener ( ( ) => Login ( new DirectLoginOptions ( DirectLoginMethod . Facebook , marketingConsentStatus : defaultMarketingConsent ) ) ) ;
344376 facebookLoginButton . interactable = IsInitialized && ! IsLoggedIn ;
345377 Debug . Log ( "[PassportManager] Configured Facebook login button" ) ;
346378 }
0 commit comments