-
20 Oct 2012 6:43 AM #1
[ST-2.1.0-RC2] iOS web apps get stuck on loading if require classes from "Ext.device"
[ST-2.1.0-RC2] iOS web apps get stuck on loading if require classes from "Ext.device"
Important note: Actual iOS web apps are not likely to ever need requesting any classes from namespace Ext.device. But when developing Sencha Touch 2 apps to be packaged as iOS native apps, it is strongly required to be able to also run them as iOS web apps (in the full-screen mode and based on UIWebView) -- otherwise code changes in them will require to do native (re-)packaging and re-uploading to iOS devices (or simulator) much more often than it used to be, which seriously affects the developers productivity.
The above is regarding all those methods that have special implementations in Sencha Touch 2 to simulate their functionality (to some reasonable extent) in Mobile Safary or in web applications. For instance, those are:
- Ext.device.Camera.updateSamples()
- Ext.device.Camera.capture()
- Ext.device.Connection.getOnline()
- Ext.device.Contacts.getContacts()
- Ext.device.Device.openURL()
- Ext.device.Geolocation.getCurrentPosition()
- Ext.device.Geolocation.watchPosition()
- Ext.device.Geolocation.clearWatch()
- Ext.device.Notification.show()
- Ext.device.Notification.vibrate()
Description:- iOS web apps get stuck on loading if they require classes from the Ext.device namespace
- No issue if running such apps inside Mobile Safari or as native (packaged) iOS apps
- The issue was introduced in Sencha Touch 2.1.0 RC2 (no such problem with RC1)
- Sencha Touch 2.1.0 RC2 (it has this issue)
- Sencha Touch 2.1.0 RC1 (no such issue)
- Mobile Safari and UIWebView (on iOS 6.0)
- Create a new project "template" with 'sencha generate app'
- Open app.js in the project's directory and modify it to require, for example, 'Ext.device.Notification':
Code:requires: [ 'Ext.device.Notification', 'Ext.MessageBox' ],- Open the application in Mobile Safary (it will start just fine) and add it to the home screen as an iOS web app
- Start the web application from the iOS home screen
- The iOS web application starts (from the iOS home screen) just as good as it does inside Mobile Safary
- The iOS web application begins starting (loading), but its screen will never go beyond the "loading indicator" (flashing dots, by default)
- In Sencha Touch 2.1.0 RC2 the internal logic has been improved as follows:
- The Ext.browser.is.WebView flag is now set not only when the app starts inside UIWebView and the app is packaged as a native iOS app, but also when it starts as an iOS web app (in which case it is still running inside UIWebView).
- That is based on testing the User-Agent header value inside Ext.env.Browser.
- In RC2 the existing logic of the classes inside namespace Ext.device was not updated in sync with the aforementioned change. For example, the constructor of Ext.device.Device is implemented as follows:
Code:constructor: function() { var browserEnv = Ext.browser.is; if (browserEnv.WebView) { if (browserEnv.PhoneGap) { return Ext.create('Ext.device.device.PhoneGap'); } else { return Ext.create('Ext.device.device.Sencha'); } } else { return Ext.create('Ext.device.device.Simulator'); } }- In RC1 (and earlier versions) iOS web apps get some of the native-app capabilities "simulated" using the corresponding Simulator implementations (as in the sample code above). In RC2, as Ext.browser.is.WebView is set for a web app, the app will attempt loading the classes that use the underlying bridge to native iOS features. That bridge is only available for packaged native iOS apps. Thus web apps based on RC2 get stuck at the loading phase.
Code:constructor: function() { var browserEnv = Ext.browser.is; if (browserEnv.WebView) { if (browserEnv.PhoneGap) { return Ext.create('Ext.device.device.PhoneGap'); } if (browserEnv.Sencha) { return Ext.create('Ext.device.device.Sencha'); } } return Ext.create('Ext.device.device.Simulator'); }
- Ext.device.Camera.updateSamples()
-
20 Oct 2012 8:49 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
Ext.device namespace is meant to be used within a packaged app. Have you tried in a packaged app?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Oct 2012 12:26 PM #3
Hi Mitchell,
I think you might have missed the note in my original report above:
Important note: Actual iOS web apps are not likely to ever need requesting any classes from namespace Ext.device. But when developing Sencha Touch 2 apps to be packaged as iOS native apps, it is strongly required to be able to also run them as iOS web apps (in the full-screen mode and based on UIWebView) -- otherwise code changes in them will require to do native (re-)packaging and re-uploading to iOS devices (or simulator) much more often than it used to be, which seriously affects the developers productivity.
I hope that explains things. (Just in case, I have also moved this note at the top of my original report above, so that it's better visible.)
-
25 Oct 2012 12:00 PM #4
Mitchell, I would truly appreciate if you or your colleagues could take another look at my original description (which I extended with some details so that it should be more clear now, I hope) and re-evaluate it.
-
26 Oct 2012 5:41 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
Thought I had seen a bug opened for this but couldn't find it so I have opened a bug in our bug tracker.
This is for the Device class to default on Simulator if WebView is true but not within Phonegap or Sencha packager (saved to homescreen)
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-3626
in
Sprint 28.


Reply With Quote