In my attempt to integrate push notifications into my iOS PhoneGap 2.0 app using the recently released Urban Airship plugin, I encountered an issue. Everything functions perfectly when I load the index.html from the provided sample application into my project. However, when I incorporate my app's index.html file, the push
variable does not have access to its prototype functions. In the sample app:
document.addEventListener("deviceready", function() {
push = window.PushNotification;
console.log(typeof window.PushNotification); => 'function'
console.log(typeof push); => 'object'
However, in my app, the same code produces the following output:
console.log(typeof push); => 'function'
As a result, push.enablePush()
and other prototype functions are inaccessible. Although I have tried various workarounds, they seem to disrupt the functionality of device registration. The exact reason for this discrepancy eludes me, but I suspect it may be due to a conflict with another plugin or some code that executes before the deviceready
event occurs.
While I believe this issue is specific to my situation, I am puzzled by the concept of assigning a variable to a function object and expecting it to store an instantiated object without using new
. How is it possible that their code works seamlessly while mine encounters difficulties?