Exception thrown after calling Purchases.setup on react-native
After some struggling setting the project up (a mere npm install did not work, I had to manually copy the framework to the project root to make it work) I'm running in the following issue:
This exception is thrown after I call the setup method
async setup(id) {
try {
this.purchases = await Purchases.setup('xxx', id);
console.log(this.purchases)
} catch (e) {
console.error(e)
}
}
2018-08-03 11:28:28.271875+0200 vpnapp[79920:4614237] -[RCPurchaserInfo activeEntitlements]: unrecognized selector sent to instance 0x6040004263c0
2018-08-03 11:28:28.275429+0200 vpnapp[79920:4614237] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCPurchaserInfo activeEntitlements]: unrecognized selector sent to instance 0x6040004263c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e33112b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c7def41 objc_exception_throw + 48
2 CoreFoundation 0x000000010e3b2024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010e2b3f78 ___forwarding___ + 1432
4 CoreFoundation 0x000000010e2b3958 _CF_forwarding_prep_0 + 120
5 vpnapp 0x000000010a89d716 -[RCPurchaserInfo(RNPurchases) dictionary] + 902
6 vpnapp 0x000000010a8a00f5 -[RNPurchases purchases:receivedUpdatedPurchaserInfo:] + 133
7 vpnapp 0x000000010a549c74 __34-[RCPurchases updatePurchaserInfo]_block_invoke + 148
8 vpnapp 0x000000010a544a02 -[RCBackend handle:withResponse:error:completion:] + 466
9 vpnapp 0x000000010a545ecf __55-[RCBackend getSubscriberDataWithAppUserID:completion:]_block_invoke + 143
10 vpnapp 0x000000010a547b06 __67-[RCHTTPClient performRequest:path:body:headers:completionHandler:]_block_invoke + 758
11 CFNetwork 0x000000010db0f454 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
12 CFNetwork 0x000000010db0ecad __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 147
13 Foundation 0x000000010c1f222f __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
14 Foundation 0x000000010c1f2091 -[NSBlockOperation main] + 68
15 Foundation 0x000000010c1f054e -[__NSOperationInternal _start:] + 778
16 libdispatch.dylib 0x00000001128ab33d _dispatch_client_callout + 8
17 libdispatch.dylib 0x00000001128b09f3 _dispatch_block_invoke_direct + 592
18 libdispatch.dylib 0x00000001128ab33d _dispatch_client_callout + 8
19 libdispatch.dylib 0x00000001128b09f3 _dispatch_block_invoke_direct + 592
20 libdispatch.dylib 0x00000001128b0783 dispatch_block_perform + 109
21 Foundation 0x000000010c1ec55c __NSOQSchedule_f + 342
22 libdispatch.dylib 0x00000001128ab33d _dispatch_client_callout + 8
23 libdispatch.dylib 0x00000001128b1754 _dispatch_continuation_pop + 967
24 libdispatch.dylib 0x00000001128afb85 _dispatch_async_redirect_invoke + 780
25 libdispatch.dylib 0x00000001128b7102 _dispatch_root_queue_drain + 772
26 libdispatch.dylib 0x00000001128b6da0 _dispatch_worker_thread3 + 132
27 libsystem_pthread.dylib 0x0000000112d77169 _pthread_wqthread + 1387
28 libsystem_pthread.dylib 0x0000000112d76be9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
How to continue from here?
Hey,
Looks like maybe you have an old version of the iOS framework. Entitlements weren't added until 1.0.0.
Can you check the contents of +RCPurchases.frameworkVersion? You can also just look inside the .framework file for the plist.
If you integrated it manually, just make sure you download the latest.
Let me know if that makes sense. You can ping me on the chat on our website and I can help in real time.
That seems to have fixed the issue, thanks!
I copied the framework from the node_modules/react-native-purchases folder, so the script must have downloaded the previous version.
Great! Let me know if anything else comes up.
Hi @jeiting , I'm having similar issue - app crashes on launch after calling setup method, on iOS 9.3.5 (it's running fine on iOS 11.4). I have downloaded latest version of the framework and copied to the project as you suggested, but the issue still persists:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFLocale currencyCode]: unrecognized selector sent to instance 0x7fc791524e50'
Any ideas?
EDIT: Looks like currencyCode is available from iOS 10.0, in SKProduct+RNPurchases.m file I have added below additional check and it stopped crashing, however I am not iOS developer so not sure if that makes any sense ;)
floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_9_x_Max)