SlideShare a Scribd company logo
StoreKit

    2011/10/30
    saku2saku
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
20111030i phonedeveloperworkshoppublished
- (void)viewDidLoad {
! if ([SKPaymentQueue canMakePayments]) {

!   !
!   !  NSSet *itemIdentifiersSet = [NSSet setWithObjects:
!   !  ! ! ! ! ! ! !            ITEM_IDENTIFIER_1,ITEM_IDENTIFIER_2,
!   !  ! ! ! ! ! ! !            ITEM_IDENTIFIER_3,ITEM_IDENTIFIER_4,
!   !  ! ! ! ! ! ! !            ITEM_IDENTIFIER_5,
!   !  ! ! ! ! ! ! !            nil];
!   !  SKProductsRequest *request = [[SKProductsRequest alloc]
                      initWithProductIdentifiers:itemIdentifiersSet];
! !    request.delegate = self;
! !    [request start];
! } else {
! !    UIAlertView *alertView = [[[UIAlertView alloc] init]
autorelease];

! !     [alertView show];
! }
}
#pragma mark -
#pragma mark SKProductsRequestDelegate

-   (void) productsRequest:(SKProductsRequest *)request
!      didReceiveResponse:(SKProductsResponse *)response {
!    for (SKProduct *product in response.products) {
!    !   [itemIdentifiers addObject:product];
!    }
!    [request autorelease];
!    [loadingView removeFromSuperview];
!    [self.tableView reloadData];
}
observer = [[ProductBuyingObserver alloc] init];
! [[SKPaymentQueue defaultQueue] addTransactionObserver:observer];


                                 or
! [[SKPaymentQueue defaultQueue] addTransactionObserver: self];
-   (void) pushBuyButton {
!    LOG_DEBUG(@"buy :%@", itemIdentifier);
!    SKPayment *payment = [SKPayment paymentWithProductIdentifier:itemIdentifier];
!    [[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:
(NSArray *)transactions {
! for (SKPaymentTransaction *transaction in transactions) {
! !    switch (transaction.transactionState) {
! !    ! case SKPaymentTransactionStatePurchasing:
             !//
! !     !   ! break;! ! ! !
! !     !   case SKPaymentTransactionStatePurchased:
               !
               //
! !     !   ! break;
! !     !   case SKPaymentTransactionStateFailed:
               !
               //
! !     !   ! break;
! !     !   case SKPaymentTransactionStateRestored:
               !
               //
!   !   !   ! break;
!   !   !   default:
!   !   !   ! break;
!   !   }
!   }
}
!   !   case 2:
!   !   {
!   !   ! if ([SKPaymentQueue canMakePayments]) {
!   !   ! ! [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
!   !   ! ! [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
!   !   ! } else {
!   !   ! ! UIAlertView *alertView = [[[UIAlertView alloc] init] autorelease];

! !     !   !   [alertView show];
! !     !   }

! !     !   break;
! !     }
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:
(NSArray *)transactions {
! for (SKPaymentTransaction *transaction in transactions) {
! !    switch (transaction.transactionState) {
! !    ! case SKPaymentTransactionStatePurchasing:
             !//
! !     !   ! break;! ! ! !
! !     !   case SKPaymentTransactionStatePurchased:
               !
               //
! !     !   ! break;
! !     !   case SKPaymentTransactionStateFailed:
               !
               //
! !     !   ! break;
! !     !   case SKPaymentTransactionStateRestored:
               !
               //
!   !   !   ! break;
!   !   !   default:
!   !   !   ! break;
!   !   }
!   }
}
- (void) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentQueue *) queue {
! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

! [alertView show];
! LOG_DEBUG(@"method called!");
}




- (void) paymentQueue:(SKPaymentQueue *)queue
restoreCompletedTransactionsFailedWithError:(NSError *) error {
! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

! [alertView show];
! LOG_DEBUG(@"method called!");
}
20111030i phonedeveloperworkshoppublished
{
! "signature" = "AkWUo       ";
! "purchase-info" = "ewoJI        ";
! "environment" = "Sandbox";
! "pod" = "100";
! "signing-status" = "0";
}
{
!   "item-id" = "471702051";
!   "original-transaction-id" = "1000000010942512";
!   "purchase-date" = "2011-10-23 07:15:02 Etc/GMT";
!   "product-id" = "com.comitter.sampleapp.sample3";
!   "transaction-id" = "1000000010942512";
!   "quantity" = "1";
!   "original-purchase-date" = "2011-10-23 07:15:02 Etc/GMT";
!   "bid" = "com.comitter.sample2";
!   "bvrs" = "1.0";
}
20111030i phonedeveloperworkshoppublished

More Related Content

PPTX
Upgrading from Angular 1.x to Angular 2.x
PPTX
AngularJS $Provide Service
PPTX
Routing And Navigation
PPTX
Angular 2 Architecture
PPTX
Angular 1.x vs. Angular 2.x
PPTX
AngularJs $provide API internals & circular dependency problem.
PDF
10 tips for a reusable architecture
Upgrading from Angular 1.x to Angular 2.x
AngularJS $Provide Service
Routing And Navigation
Angular 2 Architecture
Angular 1.x vs. Angular 2.x
AngularJs $provide API internals & circular dependency problem.
10 tips for a reusable architecture

What's hot (20)

PPTX
AngularJS Routing
PDF
Workshop 12: AngularJS Parte I
PPTX
Performance Optimization In Angular 2
PPTX
Angular 2.0 forms
PPTX
AngularJS Internal
PPTX
Modules and injector
PPTX
Template syntax in Angular 2.0
PDF
Excellent
PPTX
Http Communication in Angular 2.0
PDF
Rails is not just Ruby
PDF
Workshop 5: JavaScript testing
PPTX
AngularJS Animations
PPTX
AngularJS - $http & $resource Services
PPTX
Angular 2 - Ahead of-time Compilation
PPTX
Component lifecycle hooks in Angular 2.0
PDF
Learn You a Functional JavaScript for Great Good
PPTX
AngularJS Services
PDF
정오의 데이트 for iOS 코드 정리
PPTX
Dart and AngularDart
AngularJS Routing
Workshop 12: AngularJS Parte I
Performance Optimization In Angular 2
Angular 2.0 forms
AngularJS Internal
Modules and injector
Template syntax in Angular 2.0
Excellent
Http Communication in Angular 2.0
Rails is not just Ruby
Workshop 5: JavaScript testing
AngularJS Animations
AngularJS - $http & $resource Services
Angular 2 - Ahead of-time Compilation
Component lifecycle hooks in Angular 2.0
Learn You a Functional JavaScript for Great Good
AngularJS Services
정오의 데이트 for iOS 코드 정리
Dart and AngularDart
Ad

Viewers also liked (8)

PDF
20120616i phonedeveloperworkshop
PDF
20120219i phonedeveloperworkshoppublished
KEY
20120826i phonedeveloperworkshop
PDF
20120422i phonedeveloperworkshoppublished
PDF
CoreDataをバックグラウンドで扱うためのTips
PDF
XcodeのTargetについてのTIPS
PDF
CoreData 非同期データ処理
PDF
javascript を Xcode でテスト
20120616i phonedeveloperworkshop
20120219i phonedeveloperworkshoppublished
20120826i phonedeveloperworkshop
20120422i phonedeveloperworkshoppublished
CoreDataをバックグラウンドで扱うためのTips
XcodeのTargetについてのTIPS
CoreData 非同期データ処理
javascript を Xcode でテスト
Ad

Similar to 20111030i phonedeveloperworkshoppublished (20)

DOCX
关于Iap程序类购买使用说明
PDF
Turn your spaghetti code into ravioli with JavaScript modules
PDF
I os 11
PDF
JavaScript Promise
PDF
Working with AFNetworking
PDF
Unit Testing: Special Cases
PDF
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
PDF
Leaving Interface Builder Behind
PDF
Xamarin: Introduction to iOS 8
PDF
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
PDF
What's new in iOS 7
PDF
iOS for ERREST - alternative version
PDF
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
DOCX
Borrador del blog
PDF
Javascript MVC & Backbone Tips & Tricks
PDF
Swift Montevideo Meetup - iPhone, una herramienta medica
PDF
Swift Montevideo Meetup - iPhone, una herramienta medica
PDF
Service Workers
PDF
Tdd iPhone For Dummies
PPT
Beginning iphone 4_devlopement_chpter7_tab_b
关于Iap程序类购买使用说明
Turn your spaghetti code into ravioli with JavaScript modules
I os 11
JavaScript Promise
Working with AFNetworking
Unit Testing: Special Cases
Conceitos e prática no desenvolvimento iOS - Mobile Conf 2014
Leaving Interface Builder Behind
Xamarin: Introduction to iOS 8
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
What's new in iOS 7
iOS for ERREST - alternative version
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
Borrador del blog
Javascript MVC & Backbone Tips & Tricks
Swift Montevideo Meetup - iPhone, una herramienta medica
Swift Montevideo Meetup - iPhone, una herramienta medica
Service Workers
Tdd iPhone For Dummies
Beginning iphone 4_devlopement_chpter7_tab_b

More from Yoichiro Sakurai (14)

PDF
Objective-C/Swift コードの共用
PDF
Xcode で gulp を使うお話
PDF
開発を加速させるRetty式チーム開発術 Reloaded
PDF
チームを加速させるRetty式開発術
PDF
1人でも頑張れる!Retty式開発環境
PDF
NSInvocationの便利さとハマりどころ
PDF
Google admobmediationで広告最適化
PDF
Crashlyticsでクラッシュ撲滅作戦
PDF
TestFlight自動化でらくらくチームテスト
PDF
20130216 workshop
KEY
20121028i phonedeveloperworkshop
KEY
20120413 nestakabaneworkshop
PDF
20120316 designerworkshoppublished
KEY
20110424i phonedeveloperworkshoppublish
Objective-C/Swift コードの共用
Xcode で gulp を使うお話
開発を加速させるRetty式チーム開発術 Reloaded
チームを加速させるRetty式開発術
1人でも頑張れる!Retty式開発環境
NSInvocationの便利さとハマりどころ
Google admobmediationで広告最適化
Crashlyticsでクラッシュ撲滅作戦
TestFlight自動化でらくらくチームテスト
20130216 workshop
20121028i phonedeveloperworkshop
20120413 nestakabaneworkshop
20120316 designerworkshoppublished
20110424i phonedeveloperworkshoppublish

20111030i phonedeveloperworkshoppublished

  • 1. StoreKit 2011/10/30 saku2saku
  • 10. - (void)viewDidLoad { ! if ([SKPaymentQueue canMakePayments]) { ! ! ! ! NSSet *itemIdentifiersSet = [NSSet setWithObjects: ! ! ! ! ! ! ! ! ! ITEM_IDENTIFIER_1,ITEM_IDENTIFIER_2, ! ! ! ! ! ! ! ! ! ITEM_IDENTIFIER_3,ITEM_IDENTIFIER_4, ! ! ! ! ! ! ! ! ! ITEM_IDENTIFIER_5, ! ! ! ! ! ! ! ! ! nil]; ! ! SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:itemIdentifiersSet]; ! ! request.delegate = self; ! ! [request start]; ! } else { ! ! UIAlertView *alertView = [[[UIAlertView alloc] init] autorelease]; ! ! [alertView show]; ! } }
  • 11. #pragma mark - #pragma mark SKProductsRequestDelegate - (void) productsRequest:(SKProductsRequest *)request ! didReceiveResponse:(SKProductsResponse *)response { ! for (SKProduct *product in response.products) { ! ! [itemIdentifiers addObject:product]; ! } ! [request autorelease]; ! [loadingView removeFromSuperview]; ! [self.tableView reloadData]; }
  • 12. observer = [[ProductBuyingObserver alloc] init]; ! [[SKPaymentQueue defaultQueue] addTransactionObserver:observer]; or ! [[SKPaymentQueue defaultQueue] addTransactionObserver: self];
  • 13. - (void) pushBuyButton { ! LOG_DEBUG(@"buy :%@", itemIdentifier); ! SKPayment *payment = [SKPayment paymentWithProductIdentifier:itemIdentifier]; ! [[SKPaymentQueue defaultQueue] addPayment:payment]; }
  • 14. - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions: (NSArray *)transactions { ! for (SKPaymentTransaction *transaction in transactions) { ! ! switch (transaction.transactionState) { ! ! ! case SKPaymentTransactionStatePurchasing: !// ! ! ! ! break;! ! ! ! ! ! ! case SKPaymentTransactionStatePurchased: ! // ! ! ! ! break; ! ! ! case SKPaymentTransactionStateFailed: ! // ! ! ! ! break; ! ! ! case SKPaymentTransactionStateRestored: ! // ! ! ! ! break; ! ! ! default: ! ! ! ! break; ! ! } ! } }
  • 15. ! ! case 2: ! ! { ! ! ! if ([SKPaymentQueue canMakePayments]) { ! ! ! ! [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; ! ! ! ! [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; ! ! ! } else { ! ! ! ! UIAlertView *alertView = [[[UIAlertView alloc] init] autorelease]; ! ! ! ! [alertView show]; ! ! ! } ! ! ! break; ! ! }
  • 16. - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions: (NSArray *)transactions { ! for (SKPaymentTransaction *transaction in transactions) { ! ! switch (transaction.transactionState) { ! ! ! case SKPaymentTransactionStatePurchasing: !// ! ! ! ! break;! ! ! ! ! ! ! case SKPaymentTransactionStatePurchased: ! // ! ! ! ! break; ! ! ! case SKPaymentTransactionStateFailed: ! // ! ! ! ! break; ! ! ! case SKPaymentTransactionStateRestored: ! // ! ! ! ! break; ! ! ! default: ! ! ! ! break; ! ! } ! } }
  • 17. - (void) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentQueue *) queue { ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [alertView show]; ! LOG_DEBUG(@"method called!"); } - (void) paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *) error { ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [alertView show]; ! LOG_DEBUG(@"method called!"); }
  • 19. { ! "signature" = "AkWUo "; ! "purchase-info" = "ewoJI "; ! "environment" = "Sandbox"; ! "pod" = "100"; ! "signing-status" = "0"; }
  • 20. { ! "item-id" = "471702051"; ! "original-transaction-id" = "1000000010942512"; ! "purchase-date" = "2011-10-23 07:15:02 Etc/GMT"; ! "product-id" = "com.comitter.sampleapp.sample3"; ! "transaction-id" = "1000000010942512"; ! "quantity" = "1"; ! "original-purchase-date" = "2011-10-23 07:15:02 Etc/GMT"; ! "bid" = "com.comitter.sample2"; ! "bvrs" = "1.0"; }