이상한 앱이 있습니다. PhoneGap-InAppPurchase-iOS을 사용하여 내 phonegap 애플리케이션에 구매 한 앱을 추가하려고합니다. 그러나, 아이폰에 부하에 장치는 항상 'TypeError: 'undefined' is not an object (evaluating 'cordova.exec')
라고 말하며 그것이 내 init 실행을 멈추게한다고 생각합니다.Phonegap iphone exec에서 오류가 발생했습니다.
구매를 시도 할 때 ' InAppPurchase[js]: purchase error: product needs to be loaded before purchase, call storekit.load(...) first!'
오류가 발생하지만 내 index.js는 heres입니다.이 경우 storekit.load를 먼저 실행하고 있습니다. 두 가지 문제가 연관되어 있는지, 나머지 JS 작업이 중단되는지는 모르겠습니다. 내가 볼 수 있듯이, 나는 cordova를 가동하지 않고있어 .exec?
var app = {
initialize: function() {
this.bindEvents();
console.log("Attempting to init");
document.addEventListener('deviceready', this.onDeviceReady, false);
try {
FB.init({appId: "sdfsdfsdfsdfsd", nativeInterface: CDV.FB, useCachedDialogs: false});
console.log("FB Ready");
} catch (e) {
alert(e);
}
inappbilling.init(bSuccess, bError, {showLog:true}, "asdass");
},
bindEvents: function() {
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
window.storekit.init({
debug: true, /* Because we like to see logs on the console */
purchase: function (transactionId, productId) {
console.log('purchased: ' + productId);
},
restore: function (transactionId, productId) {
console.log('restored: ' + productId);
},
restoreCompleted: function() {
console.log('all restore complete');
},
restoreFailed: function (errCode) {
console.log('restore failed: ' + errCode);
},
error: function (errno, errtext) {
console.log('Failed: ' + errtext);
},
ready: function() {
var productIds = [
"com.asdad.asdads.asdasd"
];
window.storekit.load(productIds, function(validProducts, invalidProductIds) {
$.each(validProducts, function (i, val) {
console.log("id: " + val.id + " title: " + val.title + " val: " + val.description + " price: " + val.price);
});
if(invalidProductIds.length) {
console.log("Invalid Product IDs: " + JSON.stringify(invalidProductIds));
}
});
}
});
},
tokenHandler:function(msg) {
localStorage.setItem("Device", "ios");
console.log("Token Handler " + msg);
localStorage.setItem("PushID", msg)
},
errorHandler:function(error) {
console.log("Error Handler " + error);
alert(error);
},
// result contains any message sent from the plugin call
successHandler: function(result) {
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var pushNotification = window.plugins.pushNotification;
if (device.platform == 'android' || device.platform == 'Android') {
pushNotification.register(this.successHandler, this.errorHandler,{"senderID":"asdasdadsasd","ecb":"app.onNotificationGCM"});
}
else {
pushNotification.register(this.tokenHandler,this.errorHandler,{"badge":"true","sound":"true","alert":"true","ecb":"app.onNotificationAPN"});
}
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
},
// iOS
onNotificationAPN: function(event) {
var pushNotification = window.plugins.pushNotification;
console.log("Received a notification! " + event.alert);
console.log("event sound " + event.sound);
console.log("event badge " + event.badge);
console.log("event " + event);
if (event.alert) {
navigator.notification.alert(event.alert);
}
if (event.sound) {
var snd = new Media(event.sound);
snd.play();
}
},
// Android
onNotificationGCM: function(e) {
switch(e.event)
{
case 'registered':
if (e.regid.length > 0)
{
console.log("Regid " + e.regid);
localStorage.setItem("PushID", e.regid)
}
break;
case 'message':
// this is the actual push notification. its format depends on the data model
// of the intermediary push server which must also be reflected in GCMIntentService.java
alert(e.message);
break;
case 'error':
alert('GCM error = '+e.msg);
break;
default:
alert('An unknown GCM event has occurred');
break;
}
}
};
function bSuccess(result) {
alert("woo - initialised");
}
function bError(error) {
alert(error);
}
function updateID() {
console.log("Updating ID on server");
var Username = localStorage.getItem("Username");
var SessionKey = localStorage.getItem("SessionID");
var PushID = localStorage.getItem("PushID");
alert(PushID);
$.mobile.loading('show', { theme: "b", text: "Loading", textonly: false});
$.ajax({
crossDomain: true,
contentType: "application/json; charset=utf-8",
url: "http://taasdasdasdasdgi.asdasdasdasdasd.com/Register.asmx/RegisterDevice",
data: { Username: Username, SessionKey: SessionKey, PushId:PushID, UUid:"moo", ProductType: localStorage.getItem("Device") },
dataType: "jsonp",
success: onDataReceived
});
function onDataReceived(data)
{
$.mobile.loading('hide', { theme: "b", text: "", textonly: false});
}
}
function successHandler1 (result) {
console.log(result);
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
}
function errorHandler1 (error) {
console.log(error);
alert("ERROR: \r\n"+error);
}
function subscribe(){
// make the purchase
if (device.platform == 'android' || device.platform == 'Android') {
inappbilling.buy(successHandler1, errorHandler1,"asdasdsa");
}
else {
window.storekit.purchase("com.asdsaddas.asdasd.asdasdasd", 1);
}
console.log("Trying to buy");