-
5 Dec 2011 7:58 AM #1
Answered: Ext Application does not working in iPhone simulator, but does work in iPad simulator
Answered: Ext Application does not working in iPhone simulator, but does work in iPad simulator
Iam developing an application with Sencha Touch 2.0.0 with Phonegap 1.1.0 in Xcode but can't get it to work on an iPhone. I have stripped the whole application and found that the launch() method is never triggered on the iPhone. The first alert() is shown, but the second one never is.
The following code works on Safari, iPad, both hardware and simulator but not on the iPhone, both on hardware and simulator.
How do I get my application to run on the iPhone?HTML Code:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>AfvalApp</title> <script type="text/javascript" src="lib/touch2/sencha-touch-all.js"></script> <script type="text/javascript"> alert('js working'); Ext.application({ name: 'MyApp', launch: function() { alert('launched'); }}); </script> </head> <body> </body> </html>
-
Best Answer Posted by rdougan
Here is a very simply example of ST 2.0 PR2 and PhoneGap:
Ensure all your others to ST and PhoneGap are correct (it *must* load the PhoneGap.js file to work).Code:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sencha Touch PR2 + PhoneGap</title> <!-- include PhoneGap before anything else --> <script type="text/javascript" src="phonegap-1.2.0.js"></script> <!-- include Sencha Touch --> <link rel="stylesheet" href="sencha-touch.css" type="text/css"> <script type="text/javascript" src="sencha-touch-all.js"></script> <!-- include your application --> <script type="text/javascript"> Ext.application({ name: 'MyApp', launch: function() { alert('Launched!'); } }); </script> </head> <body></body> </html>
You do not need to do any other magic with deviceready. It is all handled by Sencha Touch.
-
5 Dec 2011 9:37 AM #2
Are you using PhoneGap?
You must include the phonegap.js file, or it will not work (phonegap bug, not a Sencha Touch bug).Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
6 Dec 2011 1:00 AM #3
Including Phonegap now loads Ext
Including Phonegap now loads Ext
Hi thanks for your reply.
I have re-included PhoneGap and now Ext is being loaded, so I am one step further. I am now going to try using PhoneGap's deviceready-event to see if I can get any further.
-
6 Dec 2011 2:14 AM #4
No working example of Sencha Touch 2.0.0 and PhoneGap
No working example of Sencha Touch 2.0.0 and PhoneGap
I have hit a new roadblock. I don't know how to start a Sencha Touch 2.0.0 application using PhoneGap.
I followed the instructions of this tutorial, but that is for Sencha Touch 1.1.0.
http://www.sencha.com/learn/a-sencha...with-phonegap/
This does not work in Sencha Touch 2.0.0:
I assume I have to use Ext.Application or Ext.Setup instead of Ext.regApplication, but none of the ways I have tried it yield any result on the iPhone.HTML Code:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title></title> <script type="text/javascript" src="lib/touch2/sencha-touch-all.js"></script> <script type="text/javascript" src="phonegap-1.1.0.js"></script> <script type="text/javascript"> document.addEventListener("deviceready", app.mainLaunch, false); Ext.regApplication({ name: 'app', launch: function() { this.launched = true; this.mainLaunch(); }, mainLaunch: function() { if (!device || !this.launched) {return;} console.log('mainLaunch'); } }); </script> </head> <body> </body> </html>
-
6 Dec 2011 10:08 AM #5
Here is a very simply example of ST 2.0 PR2 and PhoneGap:
Ensure all your others to ST and PhoneGap are correct (it *must* load the PhoneGap.js file to work).Code:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sencha Touch PR2 + PhoneGap</title> <!-- include PhoneGap before anything else --> <script type="text/javascript" src="phonegap-1.2.0.js"></script> <!-- include Sencha Touch --> <link rel="stylesheet" href="sencha-touch.css" type="text/css"> <script type="text/javascript" src="sencha-touch-all.js"></script> <!-- include your application --> <script type="text/javascript"> Ext.application({ name: 'MyApp', launch: function() { alert('Launched!'); } }); </script> </head> <body></body> </html>
You do not need to do any other magic with deviceready. It is all handled by Sencha Touch.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
7 Dec 2011 5:48 AM #6
It works when including PhoneGap first
It works when including PhoneGap first
After including PhoneGap first it now works like a charm.
This new way to launch the application is much simpler than in the previous version.
-
1 Feb 2012 8:19 AM #7
I just noticed this thread. I had no idea that ST was aware of the PhoneGap "deviceready" event. Is this mentioned in the documentation anywhere? If not, I would suggest adding it. I'm sure I'm not the only one who's had trouble coordinating that event with Ext.application().You do not need to do any other magic with deviceready. It is all handled by Sencha Touch.
-
3 Apr 2012 3:21 PM #8
sencha is not aware of deviceready
sencha is not aware of deviceready
Hello,
I'm currently testing over phonegap and I realize that launch() function is executed before deviceready event. Therefore, Sencha doesn't start properly. (Only on IOS, Android works fine)
I tried to call lunch in the onDeviceReady function, but the problem is at that point Sencha have already loaded whole view, controllers and stores set up in the Ext.Application
Is there anyway to make sencha wait until deviceready to load the Ext.Application content so after that execute the launch() function?
BR,
-
29 Nov 2012 2:59 AM #9
I'm using sencha 2.1 along with phoneGap 2.0 to run a chart app. It is working fine on iPad emulator but not on iPhone emulator.
The navigation is displayed but the charts are not. The chart i'm using is similar to energyApp of the example.
Please let me know what changes needs to be made.
Thanks in advance


Reply With Quote