@@ -108,10 +108,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
108
108
109
109
//#####################################################################
110
110
// Xamarin.Auth API - Breaking Change
111
- // old API returned UIKit.UIViewController
111
+ // old API returned global::Android.Content.Intent
112
112
//Intent ui_intent_as_object = auth.GetUI ();
113
113
// new API returns System.Object
114
- System . Object ui_intent_builder_as_object = Auth1 . GetUI ( this ) ;
114
+ System . Object ui_object = Auth1 . GetUI ( this ) ;
115
115
if ( Auth1 . IsUsingNativeUI == true )
116
116
{
117
117
//=================================================================
@@ -135,8 +135,12 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
135
135
System . Uri uri_netfx = Auth2 . GetInitialUrlAsync ( ) . Result ;
136
136
global ::Android . Net . Uri uri_android = global ::Android . Net . Uri . Parse ( uri_netfx . AbsoluteUri ) ;
137
137
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 ;
139
139
// 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.
140
144
// NOTE[s]
141
145
// * custom scheme support only
142
146
// xamarinauth://localhost
@@ -151,6 +155,9 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
151
155
. SetShowTitle ( true )
152
156
. EnableUrlBarHiding ( )
153
157
;
158
+ // TODO: warmup, prefetching
159
+ // TODO: menu
160
+ // TODO: bottom bar
154
161
//------------------------------------------------------------
155
162
// [REQUIRED] launching Custom Tabs
156
163
global ::Android . Support . CustomTabs . CustomTabsIntent ct_intent = ctib . Build ( ) ;
@@ -170,7 +177,7 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth1 oauth1)
170
177
// soon to be non-default
171
178
// optional API in the future (for backward compatibility)
172
179
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 ;
174
181
StartActivity ( i ) ;
175
182
//=================================================================
176
183
}
@@ -239,10 +246,10 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)
239
246
240
247
//#####################################################################
241
248
// 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 ();
244
251
// new API returns System.Object
245
- System . Object intent_as_object = Auth2 . GetUI ( this ) ;
252
+ System . Object ui_object = Auth2 . GetUI ( this ) ;
246
253
if ( Auth2 . IsUsingNativeUI == true )
247
254
{
248
255
//=================================================================
@@ -254,34 +261,63 @@ private void Authenticate(Xamarin.Auth.Helpers.OAuth2 oauth2)
254
261
// SafariServices.SFSafariViewController
255
262
// on 2014-04-20 google (and some other providers) will work only with this API
256
263
//
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)
258
269
//
259
270
// required part
260
271
// add
261
- // following code
262
- //
272
+ // following code:
263
273
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
+ }
275
305
else
276
306
{
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)
282
317
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
+ //=================================================================
285
321
}
286
322
287
323
return ;
0 commit comments