Hi, I have been using this method of authenticating with Twitter for years now https://github.com/ebryn/twitter-titanium. Quite literally days ago, my live apps (both Android and iOS) have just been stuck on the "pin" page and not returning to the app at all. I am currently using Ti Studio 3.4.1.201410281727, Ti SDK 3.5.1. The live apps were built with Ti SDK 3.4.x.
I am in need of some quick help here.
In looking into this, I have found that the load event has a split in events depending on whether the webview is still showing the "authorization" page. If not, it really does nothing. Except this is where the pin code can be seen and something done with it. As this really only dictates the button shown I think this should be changed.
This is the current code:
webView.addEventListener('load', function(event) { // If we're not on the Twitter authorize page if (event.url.indexOf(self.authorizeUrl) === -1) { webViewWindow.remove(loadingOverlay); actInd.hide(); // Required for Android // Switch out close button for back button if (webViewWindow.leftNavButton !== backButton) { webViewWindow.leftNavButton = backButton; } } else { // Switch out back button for close button if (webViewWindow.leftNavButton !== closeButton) { webViewWindow.leftNavButton = closeButton; } // Grab the PIN code out of the DOM var pin = event.source.evalJS("document.getElementById('oauth_pin').getElementsByTagName('code')[0].innerText"); if (!pin) { // We're here when: // - "No thanks" button clicked // - Bad username/password webViewWindow.remove(loadingOverlay); actInd.hide(); } else { ..<take care of business - removed for brevity> } } });And this is what I am thinking of changing it to ......
webView.addEventListener('load', function(event) { // If we're not on the Twitter authorize page if (event.url.indexOf(self.authorizeUrl) === -1) { webViewWindow.remove(loadingOverlay); actInd.hide(); // Required for Android // Switch out close button for back button if (webViewWindow.leftNavButton !== backButton) { webViewWindow.leftNavButton = backButton; } } else { // Switch out back button for close button if (webViewWindow.leftNavButton !== closeButton) { webViewWindow.leftNavButton = closeButton; } } // Grab the PIN code out of the DOM var pin = event.source.evalJS("document.getElementById('oauth_pin').getElementsByTagName('code')[0].innerText"); if (!pin) { // We're here when: // - "No thanks" button clicked // - Bad username/password // - Don't have a PIN yet webViewWindow.remove(loadingOverlay); actInd.hide(); } else { ..<take care of business - removed for brevity> } });Can anyone see any issues with me doing it this way? Essentially, I made the PIN check independant of the page check. Is there some method of clicks that would lead me entirely astray? It seems to work so far.....
Also, is there anything I can do outside the app I can do (since it would mean an emergency submission to the app stores)? I read here https://twittercommunity.com/t/set-application-type-to-browser/235 about adding a callbackURL to the Twitter App, and that it apparently doesn't matter what I put in, but that doesn't seem to help.