Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app is asking for AppleID when being run

I am updating my iOS app with the Apple suggested transaction VerificationController code to verify in-app purchases due to the recent "hack" published that allowed people to purchase in-ap purchases without paying due to spoofed receipts from spoofed Apple servers.

I have everything integrated, and am now testing. I have run the app several times and the verification stuff has run several times.

I want to test everything about purchasing including starting with a fresh brand new app and AppleID. So I deleted the app completely off my testing device. I created a brand new "test user" AppleID in iTunes Connect. I went to the Settings app on my test device, went to Store, and changed the default AppleID for the device to this newly created AppleID.

I re-run the app from Xcode with the debugger, which re-installs the App onto the testing device and runs it fresh.

The problem is that almost immediately on launch, the testing device puts up the AppleID password Alert-type view and asks for the password for the old AppleID that I originally used to test everything including the original in-app purchase and the verification for it. It does not ask for the password for the new device AppleID as set in the Settings app under store.

When I run it as a new app, the verification code does not run and no code from any of my routines that do anything with the Apple StoreKit stuff is run except for a solitary

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

(observer is my delegate object for the StoreKit stuff and is created but no routines in it run except init and init does nothing except set a static variable for itself to create a singleton type class)

For checking purposes, I also added in

NSLog(@"in App Delegate, payment queue transactions are %@", [[SKPaymentQueue defaultQueue] transactions]);

which shows no old transactions hanging around.

I have no clue on why it has started to ask for my AppleID of the original test user when the App is newly installed, the AppleID for the store for the device is different, and I can identify no code being run that accesses the StoreKit (except as mentioned above).

ANy insight into this would be appreciated.

ETA: Touching CANCEL in the password dialog does not cause any extra code to run in the app and does not prevent the app from running.

If I then go into the in-app purchase screen (where the app queries the store for available in-app purchases), it asks for the password again in the same way, on the OLD AppleID. I can cancel and nothing seems to happen. If I actually touch "restore purchases" button in my app, it then asks for the password on the new AppleID as set up in the Store settings. I have not gone past this point as I want to understand what is going on and don't want to mess things up by completing/attempting the restore or purchase under the new AppleID.

Thanks

like image 204
chadbag Avatar asked Jul 26 '12 00:07

chadbag


1 Answers

I had exactly the same problem and struggled for hours to solve it.

As previously mentioned, StoreKit works system-wide and the system keeps asking for login for any transaction for which

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

has not been called. I was using RMStore, looked at the source code I found this suspect lines:

if (error.code != RMStoreErrorCodeUnableToCompleteVerification) { 
    // If we were unable to complete the verification we want StoreKit to keep reminding us of the transaction
    [queue finishTransaction:transaction];
}

This is probably what happened:

  • I first purchased the product with my test Apple ID
  • I deleted the product for test purposes
  • I tried to purchase it again. At this point I entered wrong credential and RMStore did not call [[SKPaymentQueue defaultQueue] finishTransaction:.
  • The app started asking for login at every startup.

I tried to login with a different test account but still the same alert asking to login with the old Apple ID. I also deleted the Apple ID on iTunes Connect but this did not help.

Finally I managed to solve by Restoring (not Purchasing) the product with the same account. I don't know if there is another way to solve this issue (i.e. to reset the StoreKit queue). Anyway always remember to call finishTransaction in your code.

like image 184
Marco Ancona Avatar answered Oct 18 '22 17:10

Marco Ancona