1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    John2011 is on a distinguished road

      0  

    Question 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.

    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>
    How do I get my application to run on the iPhone?

  2. Here is a very simply example of ST 2.0 PR2 and PhoneGap:

    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>
    Ensure all your others to ST and PhoneGap are correct (it *must* load the PhoneGap.js file to work).

    You do not need to do any other magic with deviceready. It is all handled by Sencha Touch.

  3. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    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.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    John2011 is on a distinguished road

      0  

    Thumbs up 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.

  5. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    John2011 is on a distinguished road

      0  

    Question 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:


    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>
    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.

  6. #5
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    Here is a very simply example of ST 2.0 PR2 and PhoneGap:

    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>
    Ensure all your others to ST and PhoneGap are correct (it *must* load the PhoneGap.js file to work).

    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. #6
    Sencha User
    Join Date
    Nov 2011
    Posts
    20
    Vote Rating
    0
    John2011 is on a distinguished road

      0  

    Thumbs up 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.

  8. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    411
    Answers
    5
    Vote Rating
    17
    jweber will become famous soon enough

      0  

    Default


    You do not need to do any other magic with deviceready. It is all handled by Sencha Touch.
    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().

  9. #8
    Sencha User
    Join Date
    Feb 2012
    Posts
    18
    Answers
    1
    Vote Rating
    0
    pablogomezp is on a distinguished road

      0  

    Default 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,

  10. #9
    Sencha User
    Join Date
    Nov 2012
    Posts
    34
    Vote Rating
    0
    Jsri is on a distinguished road

      0  

    Default


    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