GTMOAuth2ViewControllerTouch and UIWebView delegate methods

344 views
Skip to first unread message

Jon Buffington

unread,
Oct 7, 2011, 6:00:26 PM10/7/11
to GTM OAuth 2 Discussion
I am trying to indicate network activity when web pages are loaded by
the GTMOAuth2ViewControllerTouch instance. I noticed that
GTMOAuth2ViewControllerTouch does not post kGTMOAuth2FetchStarted or
kGTMOAuth2FetchStopped via the UIWebView delegate methods,
webViewDidStartLoad: and webViewDidFinishLoad:, to indicate network
activity. Was this a design decision or omission?

Greg Robbins

unread,
Oct 7, 2011, 10:52:07 PM10/7/11
to gtm-o...@googlegroups.com
It's an oversight; thanks for raising the issue. I'll update the library next week to provide notifications for webview loading.

Jon Buffington

unread,
Oct 8, 2011, 6:43:43 AM10/8/11
to GTM OAuth 2 Discussion
Greg,

Awesome. Thanks for the reply and the pending update.

Greg Robbins

unread,
Oct 10, 2011, 7:15:12 PM10/10/11
to gtm-o...@googlegroups.com
This is now checked in: http://code.google.com/p/gtm-oauth2/source/detail?r=63

Do note the comment in the auth header file:

// Notification for WebView loading
//
// Note: These notifications currently accurately reflect invocation of the
//       webViewDidStartLoad/webViewDidFinishLoad delegate messages, but
//       experience indicates that UIWebView may not guarantee that those
//       delegate messages are balanced, particularly when a load is partially
//       completed and the back button is pressed, and when loading iframes.

_EXTERN NSString* const kGTMOAuth2WebViewStartedLoading _INITIALIZE_AS(@"kGTMOAuth2WebViewStartedLoading");
_EXTERN NSString* const kGTMOAuth2WebViewStoppedLoading _INITIALIZE_AS(@"kGTMOAuth2WebViewStoppedLoading");
_EXTERN NSString* const kGTMOAuth2WebViewKey            _INITIALIZE_AS(@"kGTMOAuth2WebViewKey");
_EXTERN NSString* const kGTMOAuth2WebViewStopKindKey    _INITIALIZE_AS(@"kGTMOAuth2WebViewStopKindKey");
_EXTERN NSString* const kGTMOAuth2WebViewFinished       _INITIALIZE_AS(@"finished");
_EXTERN NSString* const kGTMOAuth2WebViewFailed         _INITIALIZE_AS(@"failed");

Jon Buffington

unread,
Oct 12, 2011, 7:05:03 AM10/12/11
to GTM OAuth 2 Discussion
Greg,

Much thanks for the changes. The notifications are working well in my
case.

I did run into one issue when GTM_OAUTH2_SKIP_GOOGLE_SUPPORT is true.
The finishSignInWithError: method is not defined. Here is a patch that
resolved the issue for me:

Index: Irunurun/Third-Party/GTM-OAuth2/GTMOAuth2SignIn.m
===================================================================
--- Irunurun/Third-Party/GTM-OAuth2/GTMOAuth2SignIn.m (date
1318416958000)
+++ Irunurun/Third-Party/GTM-OAuth2/GTMOAuth2SignIn.m (revision )
@@ -596,11 +596,11 @@
[self finishSignInWithError:error];
}

+#endif // !GTM_OAUTH2_SKIP_GOOGLE_SUPPORT
+
- (void)finishSignInWithError:(NSError *)error {
[self invokeFinalCallbackWithError:error];
}
-
-#endif // !GTM_OAUTH2_SKIP_GOOGLE_SUPPORT

// convenience method for making the final call to our delegate
- (void)invokeFinalCallbackWithError:(NSError *)error {

Greg Robbins

unread,
Oct 12, 2011, 2:51:48 PM10/12/11
to gtm-o...@googlegroups.com
Thank you for pointing out the issue with the position of the conditional. I've update the source in the repository.


Reply all
Reply to author
Forward
0 new messages