3

I have a PhoneGap 2.5 application in xCode. I have installed UrbanAirship library correctly and I need to get the PushId for a device.

Using the following code psuh boject is always null. I can see in the xCode debug console that the plugin return proper data but it seems is not being passed to the PhoneGap Plugin.

Anyone have the same problem? How to solve it?

Debug Console

-[UAUser retrieveRequestSucceeded:] [Line 873] User retrieved: 200:{
  "user_id" : "UMS5WHefShemIAx9VqjlDA",
  "user_url" : "https://device-api.urbanairship.com/api/user/UMS5WHefShemIAx9VqjlDA/",
  "tags" : [ ],
  "device_tokens" : [ ],
  "device_pins" : [ ],
  "apids" : [ ],
  "has_active_subscription" : false,
  "subscriptions" : [ ],
  "ua_device_ids" : [ "0C028CFD-AA85-4C52-BD50-F8520D8A973D" ],
  "badge" : 0,
  "server_time" : "2013-05-28 09:47:56"
}

Code in index.html

        function onDeviceReady()
        {
            console.log('The Device is Ready!');

            push = window.pushNotification;
            console.log('+++ PUSH OBJ ' + push);
            console.log('+++ PUSH OBJ JSON: ' + JSON.stringify(push));


            push.registerEvent('registration', function(error, id) {
                               console.log('+++ registration Starts.');
                               console.log('+++ error is:' + error);
                               console.log('+++ id is:' + id);
                               /*
                                if(!error)
                                { 
                                console.log("+++ ID: " + id);
                                window.pushNotificationTokenId = id;
                                }
                                else {
                                console.log("AAA Push id regires error: "+error);
                                }
                                */
                               });

            // Activate the 
            push.getPushID(function(id) {
                           console.log('+++ push.getPushID id is: ' + id);
                           if (id) {
                           console.log("XXX Got push ID: " + id);
                           window.pushNotificationTokenId = id;
                           }
                           else {
                           console.log("XXX Push id is undefined");        
                           }
                           });
        }
GibboK
  • 71,848
  • 143
  • 435
  • 658

0 Answers0