I\'d like to be notified when someone makes an In-App Purchase in my App rather than wait until the next day to check iTunes Connect to see wether or not I had any sales.
<
Add Parse to your project. To do so, follow the Quick Start Guide: https://parse.com/apps/quickstart#parse_data/mobile/ios/native/existing
Once parse is setup, add PFObject *testObject = [PFObject objectWithClassName:@"TestObject"];
testObject[@"foo"] = @"bar";
[testObject saveInBackground];
to your completeTransaction code for each in-app purchase. For example:
- (void)completeTransaction:(SKPaymentTransaction *)transaction {
NSLog(@"completeTransaction...");
[self provideContentForProductIdentifier:transaction.payment.productIdentifier];
// NEW CODE
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iapra"]){
[[NSUserDefaults standardUserDefaults] setObject: @"No" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
if ([transaction.payment.productIdentifier isEqualToString:@"company.app.iap"]){
[[NSUserDefaults standardUserDefaults] setObject: @"YES" forKey:KEY];
[[NSUserDefaults standardUserDefaults] synchronize];
PFObject *testObject = [PFObject objectWithClassName:@"IAP"];
testObject[@"TEST"] = @"Purchase Successful";
[testObject saveInBackground];
}
// NEW CODE ^^
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
Don't forget to add #import
to the top of your header.h file.
I'm not quite sure there are ANY other methods out there like this. It's pretty cool, so enjoy and have fun watching your in-app purchase notifications appear in real time!