Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Ext.device.Connection.isOnline() does not work when I use Sencha packager

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    151
    Answers
    19

    Default Ext.device.Connection.isOnline() does not work when I use Sencha packager

    Following http://docs.sencha.com/touch/2-0/#!/guide/native_apis, I added the required object:

    Code:
    Ext.require('Ext.device.Connection');
    
    
    Ext.application({
        name: 'MyApp',
        //the rest of your app follows
    });
    And then in the Main.js I added the following in the initialize function:

    Code:
    if (Ext.device.Connection.isOnline()) {
        Ext.Msg.alert('You are currently connected via ' + Ext.device.Connection.getType());
    } else {
        Ext.Msg.alert('You are not currently connected');
    }
    Then we I use sencha packager to create a Android package, load it onto my phone, I get the Msg.alert: "You are not currently connected"

    Do I have to add something special to packager.json ?
    What comes around goes around

  2. #2
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Are you sure that the following permissions has been included in the "packager.json" file?

    Code:
    "permissions": [
        "INTERNET",
        "ACCESS_NETWORK_STATE"
    ],
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    151
    Answers
    19

    Default

    Nope I don't - can you point me to that in the documentation? As I don't see anything about that on http://docs.sencha.com/touch/2-0/#!/guide/native_android

    Cheers for that. I'll try it right now.
    What comes around goes around

  4. #4
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Sure, here's the doc link:

    http://docs.sencha.com/touch/2-1/#!/...tive_packaging

    Search for the "Sample Android Config File" section.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  5. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    151
    Answers
    19

    Default

    Cheers. It says the permissions will only work for Android. So how do I do this for iOS?
    What comes around goes around

  6. #6
    Sencha User
    Join Date
    Sep 2012
    Posts
    151
    Answers
    19

    Default

    Also, I just tried adding the permissions as you requested and it still doesn't work. Hmmm... Any thoughts why? I just added it to the end of my packager.json (I doubt the order is important?)
    What comes around goes around

  7. #7
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    You need to package the app using two different packager.json files, one for Android (where the permissions are needed) and one for iOS (permissions not needed).
    Just follows the docs and you should be fine.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  8. #8
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Weird...alternatively you could check for the value

    Code:
    navigator.onLine
    Code:
    if (navigator.onLine) {
        Ext.Msg.alert('You are currently connected via ' + Ext.device.Connection.getType());
    } else {
        Ext.Msg.alert('You are not currently connected');
    }
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  9. #9
    Sencha User
    Join Date
    Sep 2012
    Posts
    151
    Answers
    19

    Default

    Cheers, navigator.onLine works!

    How do we submit bug reports to Sencha?
    What comes around goes around

  10. #10
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    I'm not sure it's a bug.
    Please post your packager.json config file before to move this thread into the ST2 Bugs forum.
    Thanks.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •