Google-Store Kauf funktionstuechtig, Dialoge geadded.
This commit is contained in:
@@ -14,6 +14,10 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
|
||||
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
|
||||
// for form inputs)
|
||||
|
||||
|
||||
|
||||
$rootScope.storeinit=99;
|
||||
|
||||
$ionicPlatform.registerBackButtonAction(function(event) {
|
||||
|
||||
// Handle Android back button to avoid the application exits accidentaly
|
||||
@@ -56,6 +60,7 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
|
||||
|
||||
|
||||
function successHandler (result) {
|
||||
/*
|
||||
var strResult = "";
|
||||
if(typeof result === 'object') {
|
||||
strResult = JSON.stringify(result);
|
||||
@@ -63,10 +68,13 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
|
||||
strResult = result;
|
||||
}
|
||||
alert("SUCCESS: \r\n"+strResult );
|
||||
*/
|
||||
$rootScope.storeinit=1;
|
||||
}
|
||||
|
||||
function errorHandler (error) {
|
||||
alert("ERROR: \r\n"+error );
|
||||
//alert("ERROR: \r\n"+error );
|
||||
$rootScope.storeinit=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
angular.module('starter.controllers', [])
|
||||
|
||||
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database) {
|
||||
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope) {
|
||||
|
||||
$scope.preis="";
|
||||
$scope.name="";
|
||||
@@ -25,6 +25,7 @@ angular.module('starter.controllers', [])
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.loaddata = function() {
|
||||
$scope.items=[];
|
||||
$database.getAllBuys().then(function (result) {
|
||||
@@ -51,6 +52,7 @@ angular.module('starter.controllers', [])
|
||||
};
|
||||
|
||||
function successBuyHandler (result) {
|
||||
/*
|
||||
var strResult = "";
|
||||
if(typeof result === 'object') {
|
||||
strResult = JSON.stringify(result);
|
||||
@@ -58,9 +60,12 @@ angular.module('starter.controllers', [])
|
||||
strResult = result;
|
||||
}
|
||||
alert("SUCCESS: \r\n"+strResult );
|
||||
*/
|
||||
$timeout(consumesuccessHandler, 1000);
|
||||
}
|
||||
|
||||
function successConsumeHandler (result) {
|
||||
/*
|
||||
var strResult = "";
|
||||
if(typeof result === 'object') {
|
||||
strResult = JSON.stringify(result);
|
||||
@@ -68,18 +73,33 @@ angular.module('starter.controllers', [])
|
||||
strResult = result;
|
||||
}
|
||||
alert("SUCCESS: \r\n"+strResult );
|
||||
*/
|
||||
}
|
||||
|
||||
function errorBuyHandler (error) {
|
||||
alert("ERROR: \r\n"+error );
|
||||
var alertPopup = $ionicPopup.alert({
|
||||
title: 'Oh Nein',
|
||||
template: 'Der Kauf konnte nicht durchgeführt werden.'
|
||||
});
|
||||
|
||||
alertPopup.then(function(res) {
|
||||
console.log('Der Kauf konnte nicht durchgeführt werden');
|
||||
});
|
||||
}
|
||||
|
||||
function errorConsumeHandler (error) {
|
||||
alert("ERROR: \r\n"+error );
|
||||
var alertPopup = $ionicPopup.alert({
|
||||
title: 'Oh Nein',
|
||||
template: 'Der Kauf wurde durchgeführt, aber deine Rosen konnten freigeschaltet werden.'
|
||||
});
|
||||
|
||||
alertPopup.then(function(res) {
|
||||
console.log('Der Kauf wurde durchgeführt, aber deine Rosen konnten freigeschaltet werden');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function buysuccessHandler (result) {
|
||||
function consumesuccessHandler (result) {
|
||||
inappbilling.consumePurchase(successConsumeHandler, errorConsumeHandler, $scope.preis);
|
||||
}
|
||||
|
||||
@@ -88,7 +108,22 @@ angular.module('starter.controllers', [])
|
||||
//alert($scope.preis);
|
||||
|
||||
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
|
||||
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
|
||||
|
||||
if ($rootScope.storeinit==1){
|
||||
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
|
||||
}
|
||||
else{
|
||||
var alertPopup = $ionicPopup.alert({
|
||||
title: 'Achtung',
|
||||
template: 'Der Google-Store konnte nicht initialisiert werden.'
|
||||
});
|
||||
|
||||
alertPopup.then(function(res) {
|
||||
console.log('Store steht nicht zur Verfuegung');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user