Cordova Phonegap的InAppPurchase.js问题
我正试图用InAppPurchase插件为phonegap做一个简单的概念验证,但我似乎连最简单的事情都做不到 我的bundleID是com.XXXX.app,我的应用内产品是Test_Prod 我只是试图加载产品,这似乎是工作和购买产品 代码: 任何帮助都将不胜感激。我已经加载了产品,现在我应该可以购买了。Cordova Phonegap的InAppPurchase.js问题,cordova,in-app-purchase,Cordova,In App Purchase,我正试图用InAppPurchase插件为phonegap做一个简单的概念验证,但我似乎连最简单的事情都做不到 我的bundleID是com.XXXX.app,我的应用内产品是Test_Prod 我只是试图加载产品,这似乎是工作和购买产品 代码: 任何帮助都将不胜感激。我已经加载了产品,现在我应该可以购买了。 谢谢。看起来您是在保证加载产品列表之前开始购买的,您需要回调storekit.load-函数: 尝试以下方法: //this list needs to contain the inap
谢谢。看起来您是在保证加载产品列表之前开始购买的,您需要回调storekit.load-函数: 尝试以下方法:
//this list needs to contain the inapp-ids, not your bundle id
//atleast it does in their tests on github (see below)
var IAP = {list: [ "Test_Prod" ]};
//Give the load-function a callback which gets executed after the products are guaranteed
//to be loaded
IAP.onReady = function() {
storekit.load(IAP.list, function(products, invalidIds){
storekit.purchase("com.XXXX.app.Test_Prod");
//If the above doesn't work, try storekit.purchase("Test_Prod");
});
}
另外,你是在ios模拟器上测试这个吗?
至少在我和InApp打交道的时候,他们不能在模拟器上进行适当的测试,
2014-08-19 20:32:01.764 sample[63043:60b] Multi-tasking -> Device: YES, App: YES
2014-08-19 20:32:01.939 sample[63043:60b] Resetting plugins due to page load.
2014-08-19 20:32:02.050 sample[63043:60b] Finished load of: file:///Users/mattkuhns/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/65C605A3-1040-40EA-9A61-D28FE7F4CE80/sample.app/www/index.html
2014-08-19 20:32:02.086 sample[63043:60b] InAppPurchase[objc]: Getting products data
2014-08-19 20:32:02.087 sample[63043:60b] InAppPurchase[objc]: Set has 1 elements
2014-08-19 20:32:02.087 sample[63043:60b] InAppPurchase[objc]: - com.XXXX.app.Test_Prod
2014-08-19 20:32:02.088 sample[63043:60b] InAppPurchase[objc]: start
2014-08-19 20:32:02.089 sample[63043:60b] InAppPurchase[objc]: About to do IAP
2014-08-19 20:32:02.091 sample[63043:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
*** First throw call stack:
(
0 CoreFoundation 0x000d21e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0317e8e5 objc_exception_throw + 44
2 CoreFoundation 0x000d1fbb +[NSException raise:format:] + 139
3 StoreKit 0x03147a9f -[SKPaymentQueue addPayment:] + 659
4 sample 0x00021b68 -[InAppPurchase purchase:] + 424
5 sample 0x000199f6 -[CDVCommandQueue execute:] + 902
6 sample 0x0001920f -[CDVCommandQueue executePending] + 671
7 sample 0x00018d69 -[CDVCommandQueue enqueCommandBatch:] + 153
8 sample 0x00018f16 -[CDVCommandQueue fetchCommandsFromJs] + 182
9 sample 0x00018e2f -[CDVCommandQueue maybeFetchCommandsFromJs:] + 159
10 libobjc.A.dylib 0x0319082b -[NSObject performSelector:withObject:] + 70
11 Foundation 0x019ebe48 __NSThreadPerformPerform + 285
12 CoreFoundation 0x0005b77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
13 CoreFoundation 0x0005b10b __CFRunLoopDoSources0 + 235
14 CoreFoundation 0x000781ae __CFRunLoopRun + 910
15 CoreFoundation 0x000779d3 CFRunLoopRunSpecific + 467
16 CoreFoundation 0x000777eb CFRunLoopRunInMode + 123
17 GraphicsServices 0x0464a5ee GSEventRunModal + 192
18 GraphicsServices 0x0464a42b GSEventRun + 104
19 UIKit 0x00339f9b UIApplicationMain + 1225
20 sample 0x0001ff2c main + 92
21 sample 0x0001febd start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
//this list needs to contain the inapp-ids, not your bundle id
//atleast it does in their tests on github (see below)
var IAP = {list: [ "Test_Prod" ]};
//Give the load-function a callback which gets executed after the products are guaranteed
//to be loaded
IAP.onReady = function() {
storekit.load(IAP.list, function(products, invalidIds){
storekit.purchase("com.XXXX.app.Test_Prod");
//If the above doesn't work, try storekit.purchase("Test_Prod");
});
}