DISQUS

britg: Extending PhoneGap to Return the iPhone’s Unique Identifier

  • Zach Allia · 1 year ago
    awesome... and thanks for figuring out the keyboard issue!
  • britg · 1 year ago
    hey no problem!
  • Lieven Gekiere · 1 year ago
    I get an "undefined" after adding all this to my project ... any idea's ?
  • britg · 1 year ago
    Hmm, when and where are you getting undefined? i.e. what's the context? Are you doing something like alert(Device.uniqueIdentifier) ?

    If you can pastie your javascript code, maybe I can weed out the issue.
  • Lieven Gekiere · 1 year ago
    Here's the JS part


    *************
    var Device = {

    available: false,
    model: "",
    version: "",
    isIPhone: null,
    isIPod: null,

    init: function(model, version) {
    try {
    Device.available = __gap;
    Device.model = __gap_device_model;
    Device.version = __gap_device_version;
    Device.gapVersion = __gap_version;
    Device.uniqueIdentifier = __gap_device_uniqueid;
    } catch(e) {
    alert("GAP is not supported!")
    }
    },

    *************

    and in my page i have :

    *************
    window.onload = function()
    {
    Device.init();
    $('infomodel').innerHTML = Device.model;
    $('infoversion').innerHTML = Device.version;
    $('infouniqueid').innerHTML = Device.uniqueIdentifier;

    Device.Location.callback = updateLocationCallback;
    Device.Image.callback = 'image.lasso?data=';
    }
    ....

    *************
  • britg · 1 year ago
    Hmm, that all looks solid. Here's a silly question - you've compiled and re-run the phonegap app in xcode, correct? also, are you using your physical iphone or the simulator?
  • Lieven Gekiere · 1 year ago
    Could this be linked to the fact i'm using a 1st generation iPhone ? Is that not supported on them ?
  • britg · 1 year ago
    From everything I've read I assumed that the ID is available to all iphones
    and ipod touches. I can't find a case in my limited searching where the
    first gen iphones done return a unique Identifier, but I don't have one
    myself.
  • Lieven Gekiere · 1 year ago
    I tried implementing this again in the latest build ... but with no success. All other GAP functions do not react anymore ...

    Maybe you need to explain this to Sintaxi, so he can build it in in the next master.

    L.
  • britg · 1 year ago
    Yes, I will definitely suggest adding this in to the trunk - not sure what
    problems you're running into as I didn't see those. If you can pastebin
    your code somewhere I will try to find some time to look at it in the next
    couple days.
  • Sahil Desai · 1 year ago
    any luck with getting access to the keyboard through uiwebview? I've been racking my brain trying to find a way. the only thing I could think of was to (for my specific example), create a stringByEvaluatingJavaScriptFromString message, where the javascript looks for a specific "id" on the page and then calls .focus() on it... I was hoping it would work, but no dice. it seems although it gains focus, that isn't enough to tell the iphone to pull up the keyboard :S
  • britg · 1 year ago
    Hey Sahil - yes actually I did get the problem fixed. You can find my
    solution here:
    http://britg.com/2008/08/23/fixing-the-keyboard...

    Hope that helps!