当有人进行应用程序内购买时,有没有办法得到通知? [英] Is There A Way To Get Notified When Someone Makes An In-App Purchase?

查看:105
本文介绍了当有人进行应用程序内购买时,有没有办法得到通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人在我的应用程序中进行应用程序内购买时,我希望收到通知,而不是等到第二天检查iTunes Connect以查看是否有任何销售。

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.

有谁知道这样做的方法?如果没有,那真的很酷!

Does anyone know of a way to do this? If not, it would be really cool!

谢谢

推荐答案

将Parse添加到项目中。为此,请按照快速入门指南进行操作: https://parse.com / apps / quickstart #parse_data / mobile / ios / native / existing

Add Parse to your project. To do so, follow the Quick Start Guide: https://parse.com/apps/quickstart#parse_data/mobile/ios/native/existing

设置解析后,添加 PFObject * testObject = [ PFObject objectWithClassName:@TestObject];
testObject [@foo] = @bar;
[testObject saveInBackground];
到每个应用内购买的completeTransaction代码。例如:

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];
}

不要忘记添加 #import< Parse / Parse.h> 到header.h文件的顶部。

Don't forget to add #import <Parse/Parse.h> 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!

这篇关于当有人进行应用程序内购买时,有没有办法得到通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆