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

Promoted IAP listener not firing in 4.4.2? (working in 4.4.1) #950

Closed
cuttlas opened this issue Mar 6, 2020 · 23 comments · Fixed by #976 or #1039
Closed

Promoted IAP listener not firing in 4.4.2? (working in 4.4.1) #950

cuttlas opened this issue Mar 6, 2020 · 23 comments · Fixed by #976 or #1039
Labels
⌚️ regression Things that worked previously

Comments

@cuttlas
Copy link

cuttlas commented Mar 6, 2020

Version of react-native-iap

4.4.2

Version of react-native

0.61.5

Platforms you faced the error (IOS or Android or both?)

IOS

Expected behavior

The 'iap-promoted-product' event listener fires when opening the app using a itms-services:// link.

Actual behavior

The 'iap-promoted-product' event listener does not fire.

Tested environment (Emulator? Real Device?)

Real Device. Iphone 7.

I had a working implementation of the promoted IAP workflow that stopped working once I upgraded to the 4.4.2 version. Sounds weird being a minor release, but downgrading solved the issue.

@hyochan
Copy link
Owner

hyochan commented Mar 19, 2020

Thanks for sharing. The change is simple #938. I think we should revert this if this is causing a problem!

@hyochan hyochan added the ⌚️ regression Things that worked previously label Mar 19, 2020
@hyochan
Copy link
Owner

hyochan commented Mar 23, 2020

@cuttlas Can you also try this and come back?

@punjasin
Copy link

punjasin commented Mar 31, 2020

not work for me also downgrade also not working but clicking the acual promo in appstore is working but app close and install production one instead T^T @hyochan

@punjasin
Copy link

punjasin commented Apr 10, 2020

still doest work now i init new react-native project and test also not work

@nathantqn
Copy link

I'm facing the same problem :(

@punjasin
Copy link

appstore keep rejecting me for 2 week now T^T can someone help

@punjasin
Copy link

I'm facing the same problem :(

solve the lasted version have comment out
this part
// - (instancetype)init { // if ((self = [super init])) { // [SKPaymentQueue.defaultQueue addTransactionObserver:self]; // }

remove comment out it work like before :)

@nathantqn
Copy link

I'm facing the same problem :(

solve the lasted version have comment out
this part
// - (instancetype)init { // if ((self = [super init])) { // [SKPaymentQueue.defaultQueue addTransactionObserver:self]; // }

remove comment out it work like before :)

Many thanks, @punjasin. This piece of code is located in IAPPromotionObserver.m right?

@hyochan
Copy link
Owner

hyochan commented Apr 14, 2020

Thanks for sharing the issue wonderful people~!
Followed by the StackOverflow this is actually recommended to be written in viewDidLoad to ensure that it's only called just once! There was an issue related to this and was removed in 4.4.2. I should have to provide the readme. Sorry for that 😞

Related #971

@nathantqn
Copy link

Hi @hyochan, so the final solution for this is to uncomment the above code and that's it or do I need to do anything else. I don't understand much about the viewDidLoad method that you mentioned, where can I find it, can you add a step by step here, many thanks :(

@hyochan
Copy link
Owner

hyochan commented Apr 14, 2020

@nenjamin2405 You can find that in AppDelegate.m file in your react native project.

@nathantqn
Copy link

nathantqn commented Apr 14, 2020

@hyochan Sorry but I cannot find viewDidLoad in my AppDelegate.m. The only thing available there is

 #import "IAPPromotionObserver.h"


[IAPPromotionObserver startObserving];

I don't know much about the native code of iOS.

hyochan added a commit that referenced this issue Apr 15, 2020
@hyochan
Copy link
Owner

hyochan commented Apr 15, 2020

@nenjamin2405 Sorry, I think I've talked too quickly. I've just fixed some code and added a guide to add IAPPromotionObserver properly in your app.

Try installing react-native-iap@4.4.4 and follow the code here.

@nathantqn
Copy link

Many thanks, @hyochan, will try it and let you know

@nathantqn
Copy link

Hi @hyochan, I've just tried the newest version and added the recommended code snippet, when I terminate the app, there is an error logged in Xcode:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[IAPPromotionObserver<0x1035c85a0> dealloc]: cannot dealloc a class object.'

image

@hyochan
Copy link
Owner

hyochan commented Apr 15, 2020

@nenjamin2405 I think you don't need the dealloc. I'll change the readme. I've seen in StackOverflow. I'm not familiar with objc either 😞. It's bad.

@nathantqn
Copy link

Hi @hyochan, it's very weird that in version 4.4.4, I could receive an event from the listener of promoted purchaseIAPEmitter.addListener('iap-promoted-product'), however when the purchase is completed (via iap-promoted-product or RNIap.requestPurchase), the listener purchaseUpdatedListener will not receive any event until I kill and reopen the app. Then I updated to version 4.4.8, the IAPEmitter.addListener('iap-promoted-product') didn't work anymore, but the RNIap.requestPurchase and purchaseUpdatedListener worked fine. So which version should I use right now to leverage both promoted flow and normal RNIap.requestPurchase flow?

@hyochan
Copy link
Owner

hyochan commented Apr 27, 2020

@nenjamin2405 Have you called initConnection in iOS in 4.4.8 before adding iap-promoted-product listener?

@nathantqn
Copy link

@hyochan Bingooo!!! That's what i'm missing. Previously the initConnection is available only in the component that containsRNIap.requestPurchase, now I moved it to the outermost before adding the iap-promoted-product listener so now it works, thank youu!

By the way, I saw that in version 4.4.8 you're commenting the snippet

- (instancetype)init {
  if ((self = [super init])) {
    [SKPaymentQueue.defaultQueue addTransactionObserver:self];
  }

  return self;
}

-(void) dealloc {
  [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
}

inside IAPPromotionObserver.m.

I need to uncomment them to make the whole flow working

@hyochan
Copy link
Owner

hyochan commented Apr 29, 2020

@nenjamin2405 Ah! That's sad. I think we need to make IAPPromotionObserver and RNIap into one and share the same transaction observer. Since adding a transaction observer should be called just once to prevent other side effects as I've referred.

Since it feels like you have the debugging environment, would you like to contribute to this issue? I can reward you $30 for that in open-collective.

@nathantqn
Copy link

Hi @hyochan I'm not quite sure how can I contribute to this issue, can you explain more details

@hyochan
Copy link
Owner

hyochan commented May 1, 2020

@nenjamin2405 The goal is to merge IAPPromotionObserver to RNIap file is iOS to call addTransactionObserver:self just once.

Below are the steps you can try.

  1. Look into node_modules/react-native-iap/ios
    image
  2. Try to solve the problem and test your codes.
  3. Fork react-native-iap and paste your codes.
  4. Delete IAPPromotionObserver.m and IAPPromotionObserver.h.
  5. Give a PR.

@ghsdh3409
Copy link
Contributor

@hyochan I made PR #1039 for this issue based on the above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌚️ regression Things that worked previously
Projects
None yet
5 participants