Hallo ihr lieben,
ich bin langsam echt am verzweifeln. Ich habe einen In App kauf in meine App integriert aber wenn man auf kaufen klickt und dann den kauf bestätigt (also die Meldung die von Apple kommt) wird mein kauf nicht freigeschaltet
Eigentlich sollte ja dann die Funktion paymentQueue aufgerufen werden. Wird sie aber irgendwie leider nicht
Kann mir vielleicht irgendjemand weiter helfen oder sagen was ich falsch mache? Ich bin langsam wirklich am Ende meiner Fähigkeiten.
Achso und ja wenn man dann den kauf getätigt hat und nix passiert ist und danach auf Rester klickt wird die Premiumfunktion ohne Probleme frei geschaltet.
Vielen Dank schonmal und hoffentlich könnt ihr mir helfen! Danke!!!!
viele grüße
Timo
ich bin langsam echt am verzweifeln. Ich habe einen In App kauf in meine App integriert aber wenn man auf kaufen klickt und dann den kauf bestätigt (also die Meldung die von Apple kommt) wird mein kauf nicht freigeschaltet
Eigentlich sollte ja dann die Funktion paymentQueue aufgerufen werden. Wird sie aber irgendwie leider nicht
Kann mir vielleicht irgendjemand weiter helfen oder sagen was ich falsch mache? Ich bin langsam wirklich am Ende meiner Fähigkeiten.
Achso und ja wenn man dann den kauf getätigt hat und nix passiert ist und danach auf Rester klickt wird die Premiumfunktion ohne Probleme frei geschaltet.
Vielen Dank schonmal und hoffentlich könnt ihr mir helfen! Danke!!!!
viele grüße
Timo
Code:
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]"premiumviewcontroller.h"[/FONT][/COLOR]
[COLOR=#D12F1B][FONT=Menlo][COLOR=#78492a]#import [/COLOR]<StoreKit/StoreKit.h>[/FONT][/COLOR]
[COLOR=#4F8187][FONT=Menlo][COLOR=#bb2ca2]@interface[/COLOR]premiumviewcontroller[COLOR=#000000] ()[/COLOR][/FONT][/COLOR][FONT=Menlo]
[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]strong[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UIButton[/COLOR][COLOR=#000000] *ttt;[/COLOR][/FONT][/COLOR]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])ttt:([COLOR=#bb2ca2]id[/COLOR])sender;[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]strong[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UILabel[/COLOR][COLOR=#000000] *lable;[/COLOR][/FONT][/COLOR]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]strong[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UILabel[/COLOR][COLOR=#000000] *preis;[/COLOR][/FONT][/COLOR]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])restorebuttonaction:([COLOR=#bb2ca2]id[/COLOR])sender;[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@property[COLOR=#000000] ([/COLOR]strong[COLOR=#000000], [/COLOR]nonatomic[COLOR=#000000]) [/COLOR]IBOutlet[COLOR=#703daa]UIActivityIndicatorView[/COLOR][COLOR=#000000] *warten;[/COLOR][/FONT][/COLOR]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]
[FONT=Menlo][COLOR=#bb2ca2]@implementation[/COLOR] premiumviewcontroller{[/FONT]
[FONT=Menlo] [COLOR=#703daa]NSArray[/COLOR] *products;[/FONT]
[FONT=Menlo] [COLOR=#703daa]SKProduct[/COLOR] *premium;[/FONT]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])viewDidLoad {[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]super[/COLOR]viewDidLoad[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#bb2ca2]self[/COLOR].[COLOR=#4f8187]ttt[/COLOR].[COLOR=#703daa]hidden[/COLOR] = [COLOR=#bb2ca2]TRUE[/COLOR];[/FONT]
[COLOR=#31595D][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]self[/COLOR]fetchProducts[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR]) fetchProducts {[/FONT]
[COLOR=#703DAA][FONT=Menlo]SKProductsRequest[COLOR=#000000] *request = [[[/COLOR]SKProductsRequest[COLOR=#3d1d81]alloc[/COLOR][COLOR=#000000]][/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#3d1d81]initWithProductIdentifiers[/COLOR]:[[COLOR=#703daa]NSSet[/COLOR] [COLOR=#3d1d81]setWithArray[/COLOR]:[COLOR=#272ad8]@[[/COLOR][COLOR=#d12f1b]@"abcd"[/COLOR][COLOR=#272ad8]][/COLOR]]];[/FONT]
[FONT=Menlo] request.[COLOR=#703daa]delegate[/COLOR] = [COLOR=#bb2ca2]self[/COLOR];[/FONT]
[FONT=Menlo] [request [COLOR=#3d1d81]start[/COLOR]];[/FONT]
[FONT=Menlo]}[/FONT]
[COLOR=#78492A][FONT=Menlo]#pragma mark - SKProductsRequestDelegate[/FONT][/COLOR]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])productsRequest:([COLOR=#703daa]SKProductsRequest[/COLOR] *)request didReceiveResponse:([COLOR=#703daa]SKProductsResponse[/COLOR] *)response {[/FONT]
[FONT=Menlo] [COLOR=#bb2ca2]for[/COLOR]([COLOR=#703daa]SKProduct[/COLOR] *product [COLOR=#bb2ca2]in[/COLOR] response.[COLOR=#703daa]products[/COLOR]) {[/FONT]
[FONT=Menlo] [COLOR=#3d1d81]NSLog[/COLOR]([COLOR=#d12f1b]@"%@"[/COLOR], product);[/FONT]
[FONT=Menlo] [COLOR=#4f8187]premium[/COLOR] = product;[/FONT]
[FONT=Menlo] [COLOR=#bb2ca2]self[/COLOR].[COLOR=#4f8187]button[/COLOR].[COLOR=#703daa]hidden[/COLOR] = [COLOR=#bb2ca2]FALSE[/COLOR];[/FONT]
[FONT=Menlo] [COLOR=#703daa]NSNumberFormatter[/COLOR] *numberFormatter = [[[COLOR=#703daa]NSNumberFormatter[/COLOR] [COLOR=#3d1d81]alloc[/COLOR]] [COLOR=#3d1d81]init[/COLOR]];[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [numberFormatter [/COLOR]setNumberStyle[COLOR=#000000]:[/COLOR]NSNumberFormatterCurrencyStyle[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#bb2ca2]self[/COLOR].[COLOR=#4f8187]preis[/COLOR].[COLOR=#703daa]text[/COLOR] = [numberFormatter [COLOR=#3d1d81]stringFromNumber[/COLOR]:product.[COLOR=#703daa]price[/COLOR]];[/FONT]
[FONT=Menlo] [COLOR=#bb2ca2]self[/COLOR].[COLOR=#4f8187]warten[/COLOR].[COLOR=#703daa]hidden[/COLOR] = [COLOR=#bb2ca2]TRUE[/COLOR];[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])request:([COLOR=#703daa]SKRequest[/COLOR] *)request didFailWithError:([COLOR=#703daa]NSError[/COLOR] *)error {[/FONT]
[FONT=Menlo] [COLOR=#3d1d81]NSLog[/COLOR]([COLOR=#d12f1b]@"%@"[/COLOR], error);[/FONT]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])ttt:([COLOR=#bb2ca2]id[/COLOR])sender {[/FONT]
[FONT=Menlo] [COLOR=#3d1d81]NSLog[/COLOR]([COLOR=#d12f1b]@"1"[/COLOR]);[/FONT]
[FONT=Menlo] [COLOR=#703daa]SKPayment[/COLOR] *payment = [[COLOR=#703daa]SKPayment[/COLOR] [COLOR=#3d1d81]paymentWithProduct[/COLOR]:[COLOR=#4f8187]premium[/COLOR]];[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]addPayment[COLOR=#000000]:payment];[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]-([COLOR=#bb2ca2]void[/COLOR])paymentQueueRestoreCompletedTransactionsFinished:([COLOR=#703daa]SKPaymentQueue[/COLOR] *)queue {[/FONT]
[COLOR=#31595D][FONT=Menlo][COLOR=#000000] [[/COLOR][COLOR=#bb2ca2]self[/COLOR]unlockFeature[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#D12F1B][FONT=Menlo][COLOR=#3d1d81]NSLog[/COLOR][COLOR=#000000]([/COLOR]@"restore erfolgreich"[COLOR=#000000]);[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]-([COLOR=#bb2ca2]void[/COLOR])unlockFeature[/FONT]
[FONT=Menlo]{[/FONT]
[COLOR=#D12F1B][FONT=Menlo][COLOR=#3d1d81]NSLog[/COLOR][COLOR=#000000]([/COLOR]@"tatata"[COLOR=#000000]);[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[FONT=Menlo]- ([COLOR=#bb2ca2]IBAction[/COLOR])restorebuttonaction:([COLOR=#bb2ca2]id[/COLOR])sender {[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]addTransactionObserver[COLOR=#000000]:[/COLOR][COLOR=#bb2ca2]self[/COLOR][COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]restoreCompletedTransactions[COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[FONT=Menlo]}[/FONT]
[COLOR=#78492A][FONT=Menlo]#pragma mark - SKPaymentTransactionObserver[/FONT][/COLOR]
[FONT=Menlo]- ([COLOR=#bb2ca2]void[/COLOR])paymentQueue:([COLOR=#703daa]SKPaymentQueue[/COLOR] *)queue updatedTransactions:([COLOR=#703daa]NSArray[/COLOR] *)transactions {[/FONT]
[FONT=Menlo] [COLOR=#bb2ca2]for[/COLOR]([COLOR=#703daa]SKPaymentTransaction[/COLOR] *tx [COLOR=#bb2ca2]in[/COLOR] transactions) {[/FONT]
[COLOR=#703DAA][FONT=Menlo][COLOR=#bb2ca2]switch[/COLOR][COLOR=#000000](tx.[/COLOR]transactionState[COLOR=#000000]) {[/COLOR][/FONT][/COLOR]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#bb2ca2]case[/COLOR]SKPaymentTransactionStatePurchased[COLOR=#000000]:[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#3d1d81]NSLog[/COLOR]([COLOR=#d12f1b]@"Unlock %@"[/COLOR], tx.[COLOR=#703daa]payment[/COLOR].[COLOR=#703daa]productIdentifier[/COLOR]);
[COLOR=#000000] [[/COLOR][COLOR=#BB2CA2]self[/COLOR][COLOR=#31595D]unlockFeature[/COLOR][COLOR=#000000]];[/COLOR][/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]finishTransaction[COLOR=#000000]:tx];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#bb2ca2]break[/COLOR];[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#bb2ca2]case[/COLOR]SKPaymentTransactionStateFailed[COLOR=#000000]:[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#3d1d81]NSLog[/COLOR]([COLOR=#d12f1b]@"Error: %@"[/COLOR], tx.[COLOR=#703daa]error[/COLOR]);[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]finishTransaction[COLOR=#000000]:tx];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#bb2ca2]break[/COLOR];[/FONT]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#bb2ca2]case[/COLOR]SKPaymentTransactionStateRestored[COLOR=#000000]:[/COLOR][/FONT][/COLOR]
[COLOR=#703DAA][FONT=Menlo][COLOR=#3d1d81]NSLog[/COLOR][COLOR=#000000]([/COLOR][COLOR=#d12f1b]@"Unlock %@"[/COLOR][COLOR=#000000], tx.[/COLOR]originalTransaction[COLOR=#000000].[/COLOR]payment[COLOR=#000000].[/COLOR]productIdentifier[COLOR=#000000]);
[/COLOR][COLOR=#000000] [[/COLOR][COLOR=#BB2CA2]self[/COLOR][COLOR=#31595D]unlockFeature[/COLOR][COLOR=#000000]];[/COLOR][/FONT][/COLOR]
[COLOR=#3D1D81][FONT=Menlo][COLOR=#000000] [[[/COLOR][COLOR=#703daa]SKPaymentQueue[/COLOR]defaultQueue[COLOR=#000000]] [/COLOR]finishTransaction[COLOR=#000000]:tx];[/COLOR][/FONT][/COLOR]
[FONT=Menlo] [COLOR=#bb2ca2]break[/COLOR];[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo]}[/FONT]
[COLOR=#BB2CA2][FONT=Menlo]@end[/FONT][/COLOR]