관찰자 클래스에서 메인 클래스로 알림을 전달하는 알림 설정이있는 인앱 구매 섹션을 수행 중입니다. 나는이 부호를 가지고있다NSNotification이 왜 반복 되는가?
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for(SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
// Item is still in the process of being purchased
break;
case SKPaymentTransactionStatePurchased:
// Item was successfully purchased!
// --- UNLOCK FEATURE OR DOWNLOAD CONTENT HERE ---
// The purchased item ID is accessible via
// transaction.payment.productIdentifier
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_DataComplete object:nil] ;
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_DataCompletehindi object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_DataCompletetamil object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_DataCompletetelugu object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_DataCompletekannada object:nil];
// After customer has successfully received purchased content,
// remove the finished transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
case SKPaymentTransactionStateRestored:
// Verified that user has already paid for this item.
// Ideal for restoring item across all devices of this customer.
// --- UNLOCK FEATURE OR DOWNLOAD CONTENT HERE ---
// The purchased item ID is accessible via
// transaction.payment.productIdentifier
// After customer has restored purchased content on this device,
// remove the finished transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
case SKPaymentTransactionStateFailed:
// Purchase was either cancelled by user or an error occurred.
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_Datacomplteing object:nil];
if (transaction.error.code != SKErrorPaymentCancelled) {
}
// Finished transactions should be removed from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
}
}
}
나는이 주된 통역에이 통보를 건네지 만, 나는 반복적 인 통보를 받고있다. 알림은 매번 반복되며 알림 이름에 해당하는 관찰자 클래스에서 올바른 알림을받지 못했습니다. 어떻게 해결할 수 있습니까?
편집 : 나는이 같은 다섯 alertviews이 :
다음if
{
}
elseif
{
}
else if
{
}
else if(alertView == kannadaPurchasedAlert)
{
if (buttonIndex==0)
{
NSString *connectionstring = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]];
if ([connectionstring length]==0) {
proAlertView *alert = [[proAlertView alloc]initWithTitle:nil message:@"you are not connected to the internet" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] withStrokeColor:[UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:1.0]];
[alert show];
[alert release];
}
else
{
[NSThread detachNewThreadSelector: @selector(spinBegininapp) toTarget:self withObject:nil];
// Replace "Your IAP Product ID" with your actual In-App Purchase Product ID.
SKPayment *paymentRequest = [SKPayment paymentWithProductIdentifier: @"com.touch.MyApp.MyApp.Kannada"];
// Assign an Observer class to the SKPaymentTransactionObserver,
// so that it can monitor the transaction status.
[[SKPaymentQueue defaultQueue] addTransactionObserver:inappObserver];
// Request a purchase of the selected item.
[[SKPaymentQueue defaultQueue] addPayment:paymentRequest];
// Register observer for when download of data is complete
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadDataCompletekannada:) name:NOTIF_DataCompletekannada object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadDataCompleting:) name:NOTIF_Datacomplteing object:nil];
amtk = 0.0;
}
}
내가
extern NSString * const NOTIF_DataComplete;
extern NSString * const NOTIF_Datacomplteing;
extern NSString * const NOTIF_FIRSTLAUNCH;
extern NSString * const NOTIF_DataCompletehindi;
extern NSString * const NOTIF_DataCompletetamil;
extern NSString * const NOTIF_DataCompletetelugu;
extern NSString * const NOTIF_DataCompletekannada;
메인 클래스에서 알림을 추가 할 위치를 게시 할 수 있습니까? – danh
@danh yeaa reply.i에 대한 감사합니다 .i는 inapp.so의 다른 제품 ID로 다운로드 할 5 권의 책을 가지고 있습니다. 5 가지 버튼이 있습니다. 각 버튼은 각 언어 팩에 해당하므로, 이름에 대한 알림을 전달합니다. 내 편집을 참조하십시오. – stackiphone
@danh 한 가지 더, evry 것은 첫 번째 알림이있는 버튼을 누른 다음 두 번째 예를 들어이 NOTIF_DataComplete, then NOTIF_DataComplete 힌트를 사용하여 ther 버튼을 누른 다음 올바른 순서로 누른 다음 순서대로 버튼을 누르면 완벽하게 작동합니다. NOTIF_DataCompletekannada를 포함하여 알림을 탭하면 처음으로 NOTIF_DataComplete 알림을 받게됩니다. – stackiphone