@@ -108,10 +108,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
108108
109109 //#####################################################################
110110 // Xamarin.Auth API - Breaking Change
111- // old API returned UIKit.UIViewController
111+ // old API returned global::Android.Content.Intent
112112 //Intent ui_intent_as_object = auth.GetUI ();
113113 // new API returns System.Object
114- System . Object ui_intent_builder_as_object = Auth1 . GetUI ( this ) ;
114+ System . Object ui_object = Auth1 . GetUI ( this ) ;
115115 if ( Auth1 . IsUsingNativeUI == true )
116116 {
117117 //=================================================================
@@ -135,8 +135,12 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
135135 System . Uri uri_netfx = Auth2 . GetInitialUrlAsync ( ) . Result ;
136136 global ::Android . Net . Uri uri_android = global ::Android . Net . Uri . Parse ( uri_netfx . AbsoluteUri ) ;
137137 global ::Android . Support . CustomTabs . CustomTabsIntent . Builder ctib ;
138- ctib = ( global ::Android . Support . CustomTabs . CustomTabsIntent . Builder ) ui_intent_builder_as_object ;
138+ ctib = ( global ::Android . Support . CustomTabs . CustomTabsIntent . Builder ) ui_object ;
139139 // add custom schema (App Linking) handling
140+ // 1. add Activity with IntentFilter to the app
141+ // 1.1. Define sheme[s] and host[s] in the IntentFilter
142+ // 1.2. in Activity's OnCreate extract URL with custom schema from Intent
143+ // 1.3. parse OAuth data from URL obtained in 1.2.
140144 // NOTE[s]
141145 // * custom scheme support only
142146 // xamarinauth://localhost
@@ -151,6 +155,9 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
151155 . SetShowTitle ( true )
152156 . EnableUrlBarHiding ( )
153157 ;
158+ // TODO: warmup, prefetching
159+ // TODO: menu
160+ // TODO: bottom bar
154161 //------------------------------------------------------------
155162 // [REQUIRED] launching Custom Tabs
156163 global ::Android . Support . CustomTabs . CustomTabsIntent ct_intent = ctib . Build ( ) ;
@@ -170,7 +177,7 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
170177 // soon to be non-default
171178 // optional API in the future (for backward compatibility)
172179 global ::Android . Content . Intent i = null ;
173- i = ( global ::Android . Content . Intent ) ui_intent_builder_as_object ;
180+ i = ( global ::Android . Content . Intent ) ui_object ;
174181 StartActivity ( i ) ;
175182 //=================================================================
176183 }
@@ -239,10 +246,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)
239246
240247 //#####################################################################
241248 // Xamarin.Auth API - Breaking Change
242- // old API returned Intent
243- //Intent intent = auth.GetUI ();
249+ // old API returned global::Android.Content. Intent
250+ //Intent ui_intent_as_object = auth.GetUI ();
244251 // new API returns System.Object
245- System . Object intent_as_object = Auth2 . GetUI ( this ) ;
252+ System . Object ui_object = Auth2 . GetUI ( this ) ;
246253 if ( Auth2 . IsUsingNativeUI == true )
247254 {
248255 //=================================================================
@@ -254,34 +261,63 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)
254261 // SafariServices.SFSafariViewController
255262 // on 2014-04-20 google (and some other providers) will work only with this API
256263 //
257- // 2017-03-25 NEW UPCOMMING API undocumented work in progress
264+ //
265+ // 2017-03-25
266+ // NEW UPCOMMING API undocumented work in progress
267+ // soon to be default
268+ // optional API in the future (for backward compatibility)
258269 //
259270 // required part
260271 // add
261- // following code
262- //
272+ // following code:
263273 System . Uri uri_netfx = Auth2 . GetInitialUrlAsync ( ) . Result ;
264- global ::Android . Net . Uri uri_android = global ::Android . Net . Uri . Parse ( uri_netfx . AbsoluteUri ) ;
265-
266- // Add Android.Support.CustomTabs package
267- global ::Android . Support . CustomTabs . CustomTabsActivityManager ctam = null ;
268- ctam = new global ::Android . Support . CustomTabs . CustomTabsActivityManager ( this ) ;
269-
270- global ::Android . Support . CustomTabs . CustomTabsIntent cti = null ;
271- cti = ( global ::Android . Support . CustomTabs . CustomTabsIntent ) intent_as_object ;
272-
273- cti . LaunchUrl ( this , uri_android ) ;
274- }
274+ global ::Android . Net . Uri uri_android = global ::Android . Net . Uri . Parse ( uri_netfx . AbsoluteUri ) ;
275+ global ::Android . Support . CustomTabs . CustomTabsIntent . Builder ctib ;
276+ ctib = ( global ::Android . Support . CustomTabs . CustomTabsIntent . Builder ) ui_object ;
277+ // add custom schema (App Linking) handling
278+ // 1. add Activity with IntentFilter to the app
279+ // 1.1. Define sheme[s] and host[s] in the IntentFilter
280+ // 1.2. in Activity's OnCreate extract URL with custom schema from Intent
281+ // 1.3. parse OAuth data from URL obtained in 1.2.
282+ // NOTE[s]
283+ // * custom scheme support only
284+ // xamarinauth://localhost
285+ // xamarin-auth://localhost
286+ // xamarin.auth://localhost
287+ // * no http[s] scheme support
288+ //------------------------------------------------------------
289+ // [OPTIONAL] UI customization
290+ // CustomTabsIntent.Builder
291+ ctib
292+ . SetToolbarColor ( color_xamarin_blue )
293+ . SetShowTitle ( true )
294+ . EnableUrlBarHiding ( )
295+ ;
296+ // TODO: warmup, prefetching
297+ // TODO: menu
298+ // TODO: bottom bar
299+ //------------------------------------------------------------
300+ // [REQUIRED] launching Custom Tabs
301+ global ::Android . Support . CustomTabs . CustomTabsIntent ct_intent = ctib . Build ( ) ;
302+ ct_intent . LaunchUrl ( this , uri_android ) ;
303+ //=================================================================
304+ }
275305 else
276306 {
277- // OLD API undocumented work in progress (soon to be deprecated)
278- // set to false to use old embedded browser API WebView and UIWebView
279- // on 2014-04-20 google login (and some other providers) will NOT work with this API
280- // This will be left as optional API for some devices (wearables) which do not support
281- // Chrome Custom Tabs on Android.
307+ //=================================================================
308+ // Xamarin.Auth API - embedded browsers support
309+ // - Android - WebView
310+ // - iOS - UIWebView
311+ //
312+ // on 2014-04-20 google (and some other providers) will work only with this API
313+ //
314+ // 2017-03-25
315+ // soon to be non-default
316+ // optional API in the future (for backward compatibility)
282317 global ::Android . Content . Intent i = null ;
283- i = ( global ::Android . Content . Intent ) intent_as_object ;
284- StartActivity ( i ) ;
318+ i = ( global ::Android . Content . Intent ) ui_object ;
319+ StartActivity ( i ) ;
320+ //=================================================================
285321 }
286322
287323 return ;
0 commit comments