donburks
1/9/2013 - 10:57 PM

gistfile1.txt

function on_reg(error, pushID) {                                                                      
    if (!error) {                                                                                     
        alert("Reg Success: " + pushID)                                                               
    }                                                                                                 
}                                                                                                     

function onDeviceReady() {                                                                            

  //UA push setup                                                                                   
  push = window.pushNotification;                                                                   

  push.registerEvent('registration', on_reg);                                                       
                                                                                                      
    // Reset Badge on resume                                                                          
    document.addEventListener("resume", function() {                                                  
        push.resetBadge()                                                                             
    })                                                                                                
                                                                                                      
    // Check if push is enabled                                                                       
    push.isPushEnabled(function(enabled) {                                                            
        if (!enabled) {                                                                               
            push.enablePush();                                                                        
            push.registerForNotificationTypes(push.notificationType.sound | push.notificationType.alert);      
        }                                                                                             
    }); 
    
    push.getPushID(function(id) {                                                                     
        alert("PUSH ID: " + id);   //Debug statement                                                   
    }); 
}