19 July 2017
Important Google IAP Plugin Update
Corona Labs’ engineering team has made an important update to the Google In-App Purchase plugin that you need to be aware of.
Starting with Corona daily build 2017.3105, the store.init() call for Google IAP is now asynchronous. This means that it will return immediately while it continues to initialize in the background. This change was made to help reduce the number of ANR or “Application Not Responding” messages being reported in the Google Play Console.
Basically, ANR reports can occur when Android senses that an app appears non-responsive — this may happen when performing synchronous network activity on a poor network connection. During testing, it’s hard to see
store.init() taking any time because it normally completes in just milliseconds, but when users have slower connections, the time can increase dramatically and trigger an ANR report.
Because of this change, you should modify how your app uses the Google IAP plugin.
While many developers already delay the store.loadProducts() call until the user reaches a place where products are listed, some developers call store.loadProducts() immediately after calling store.init() (the first mandatory call to get things rolling).
Under this new model, you should wait until you receive an
"init" callback indicating that Google IAP is completely initialized and ready to process requests (this applies to store.restore() as well).
The updated version of the plugin generates a new init event which is dispatched to the transaction listener specified within store.init(). This event has the unique
event.name property with a value of
"init" which you can use to differentiate it between storeTransaction events which must be handled by the same listener. Please see the documentation for an example of doing so.
Remember, these changes only affect Corona build 2017.3105 and later.
In addition to this update, we have fixed a Null Pointer Reference (NPR) error in the Amazon IAP plugin. This fix is available in all versions.