Phonegap IOS - Plugin Push Setup

前端 未结 2 803
遇见更好的自我
遇见更好的自我 2020-12-22 05:27

I\'m developing an App using Phonegap and Phonegap Build. The app has been pretty much completed but I\'m not working on the Push Notifications.

I\'m struggling to g

2条回答
  •  青春惊慌失措
    2020-12-22 06:03

    You are not using the this context correctly. This is a common mistake. The Javascript this does NOT work like the Java this.

    The reason it does not work is because the this gets resolved at run-time, not assemble-time (or compile-time). When the event fires, this resolves to the the global this because your app object is now out of scope. The event fires *outside* of your app object.

    A quick fix would be to do app.onDeviceReady instead of this.onDeviceReady You can test this by making youronDeviceReady() a global function and leaving the this in place.

    These videos should help. – Best of Luck.

    • Context in JavaScript - 1/4 - Purpose and Problems with JavaScript's "This"

    • Context in JavaScript - 2/4 - How JavaScript Decides What "This" Actually Is

    • Context in JavaScript - 3/4 - "This" May Not Be What You Expected & How to Fix It

    • Context in JavaScript - 4/4 - Mastering "This:" Additional Techniques & Future Support

提交回复
热议问题