j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.3k stars 537 forks source link

Exception calling native with command :: InAppBillingPlugin :: init ::exception=ReferenceError: 'Windows' is undefined #409

Closed alayham closed 6 years ago

alayham commented 8 years ago

In my 3 ionic apps, Android purchase works perfectly, but windows can not interact with the store. My log shows:

The App (debug and release) works normally on windows, but all store actions are void. I am unable to troubleshoot any further, and I need your help.

Thanks.

alayham commented 8 years ago

Activated store.DEBUG, and moved the init function to the end of $ionicPlatform.ready(function() {

[store.js] DEBUG: store.queries !! 'sku1 registered' [store.js] DEBUG: store.queries !! 'non consumable registered' [store.js] DEBUG: store.queries !! 'registered' [store.js] DEBUG: store.queries !! 'sku1 updated' [store.js] DEBUG: store.queries !! 'non consumable updated' [store.js] DEBUG: store.queries !! 'updated' Registered sku1 [store.js] DEBUG: queries ++ 'sku1 approved' [store.js] DEBUG: queries ++ 'sku1 updated' [store.js] DEBUG: store.trigger -> triggering action refreshed [store.js] DEBUG: queries !! 'refreshed' InAppBilling[js]: setup ok InAppBilling[js]: load ["sku1"] Exception calling native with command :: InAppBillingPlugin :: init ::exception=ReferenceError: 'Windows' is undefined

alayham commented 8 years ago

Using a new windows 10 machine, I downloaded the app from the store and connected it to Weinre. Still the same issue.

dkarzon commented 8 years ago

Sounds like you are missing core Windows libraries in your app. Which cordova platform are you using for your windows app? Are you building for 8.1 or 10? Does your windows solution have a reference to the Windows Library for JavaScript 2.0?

alayham commented 8 years ago

I am using ionic and building from the CLI not from visual studio. I tried this now: ionic platform rm windows ionic platform add windows ionic run windows --release --arch=x86

Same error.

dkarzon commented 8 years ago

What version of Ionic are you using and what version of the windows platform is it bringing down? I just did a test now with Ionic 1.7.14 and windows platform 4.3.1 and didn't get that error.

Are there any other javascript errors you get before that one? Are you running your store code on deviceready?

alayham commented 8 years ago

I tried adding the reference to Windows Library for JavaScript 2.0 manually. Compile failed warning MSB3783: Project "CordovaApp.Windows10" depends upon SDK "Windows Library for JavaScript 2.0 v1.0" which was released originally for apps targeting "UAP 8.1". To verify whether "Windows Library for JavaScript 2.0 v1.0" is compatible with "UAP 10.0.10240.0", contact the SDK author or see http://go.microsoft.com/fwlink/?LinkID=309181

Your system information:

Cordova CLI: 6.0.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Version: 1.2.4 Ionic CLI Version: 2.0.0-beta.17 Ionic App Lib Version: 2.0.0-beta.8 OS: Node Version: v5.6.0

Installed platforms: android 5.1.0, windows 4.3.1 Available platforms: amazon-fireos, blackberry10, browser, firefoxos, webos, windows8, wp8

Yes, I have a console.log on device ready, and It is logged before anything else. Yes, I have StoreService.initStore as the last line in $ionicPlatform.ready(function() {

and I see WinJS under platform_www in the windows platform prepared files. I am not sure it is loaded. I will try to add it manually to the prepapred index.html and recompile.

alayham commented 8 years ago

I checked the compiled file in weinre. there is a script reference to /www/WinJS/js/base.js

alayham commented 8 years ago

I am unable to see any other errors in the app. however, I tried this in $ionicPlatform.ready(function() { var package = Windows.ApplicationModel.Package.current; var packageId = package.id; console.log('Package id: ' + packageId); It did not print anything, and I could not catch any error.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.