Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase SDK crashes app on in-app purchase completion with: [__NSCFBoolean timeIntervalSince1970]: unrecognized selector sent to instance #4176

Closed
ansonl opened this issue Oct 27, 2019 · 6 comments
Milestone

Comments

@ansonl
Copy link

ansonl commented Oct 27, 2019

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 11.0
  • Firebase SDK version: 6.11.0
  • Firebase Component: Core/Unknown
  • Component version: 6.11.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Import frameworks for Firebase Analytics into project. (I am not sure which framework exactly is causing the crash.)

Complete an in app purchase in an iOS app with the transaction status of Purchased or Restored.
After the iOS callbacks for transaction finished have completed, the application will crash with the below debug text:

2019-10-27 15:49:05.517220-0400 Viewer[1750:856110] -[__NSCFBoolean timeIntervalSince1970]: unrecognized selector sent to instance 0x1eba82ff8
2019-10-27 15:49:05.518940-0400 Viewer[1750:856110] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean timeIntervalSince1970]: unrecognized selector sent to instance 0x1eba82ff8'
*** First throw call stack:
(0x1bb9a6190 0x1bab7b9f8 0x1bb8c29cc 0x1bb9ab9d8 0x1bb9ad66c 0x100d4b4f4 0x100d4cdb4 0x100d4d42c 0x100f636f4 0x100f64c78 0x100f67ad4 0x100f75dc8 0x100f767ac 0x1bb5c21b4 0x1bb5c4cd4)
libc++abi.dylib: terminating with uncaught exception of type NSException

This behavior occurs 100% of the time.

Relevant Code:

Initiate FIRApp in your code.

After creating an SKProduct with an identifier string for the app id in App Store Connect, successfully make a purchase in the sandbox similar to below.

- (void)requestPaymentForProduct:(SKProduct *)product {
  SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
  payment.quantity = 1;
  //payment.simulatesAskToBuyInSandbox= YES;
  [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
  [[SKPaymentQueue defaultQueue] addPayment:payment];
}

After the purchase completes or is restored and the Apple "success popup" shows, the application will crash with the mentioned message.

This issue has also been reported at Firebase google support online with Case 00018902

@ryanwilson
Copy link
Member

Thanks for the report, tracked internally at b/143455671

@otondin
Copy link

otondin commented Oct 28, 2019

@ansonl same here! I've noticed this crash since two weeks ago and was trying to debug to found some issue and didn't find anything indeed on my app project. Thank you for reporting.

@ansonl
Copy link
Author

ansonl commented Oct 29, 2019

I found a similar unsolved report on Stack Overflow reported last year here.

@ansonl
Copy link
Author

ansonl commented Nov 2, 2019

@ryanwilson I did some more testing, this exception always occurs when the NSUserDefaults key that is the same as the iAP product ID key is has a default prefs value registered like so:

#define kTipPurchasedIAPProductIdKey @"tipAdditional99Cents"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Override point for customization after application launch.
  
  
  if (YES) {
      //Firebase initialization
      [FIRApp configure];
      [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
  }
 
    //Register user defaults
    [[NSUserDefaults standardUserDefaults] registerDefaults:@{
                                                              kTipPurchasedIAPProductIdKey: @NO
                                                              }];
}

In this case the IAP product ID key (that you would use to validate whether the iAP exists, etc) is tipAdditional99Cents. The crash occurs when the transaction returns as purchased/restored.

Seems like Firebase is monitoring the user preferences key but this is not documented anywhere.

@baolocdo
Copy link

baolocdo commented Nov 5, 2019

@ansonl : Thanks for the reproduction steps. The issue is that registerDefaults will set values to all of the user defaults even with different domains from the shared user defaults.
We have identified the issue and will release the bug fix in the next release.

@paulb777 paulb777 added this to the M60 milestone Nov 5, 2019
@ryanwilson
Copy link
Member

Firebase 6.13.0 was just released and should address this issue. Please update and re-open if you're still seeing the issue, thanks!

@firebase firebase locked and limited conversation to collaborators Dec 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants