![]() So let's go ahead and set it to be like a dark gray. Let's change the background color when we are subscribe. You know what? Why don't we do some more fun stuff? Why don't we say something like self dot, well, not self. We're going to update the label to red if it's not true. If the status comes in as true, we're updating the label. ![]() So let's just verify that everything is good. Is that the notifications are never being removed and they might be getting stuck in memory which could be a part of our problem here. So, yeah, I think that this will help removing the observers from storefront VC because that is actually, that might be the source of our issue here. Okay, I can go into my different view controllers. It does appear that it is sending through. So we're going to just go ahead and hang tight while the subscription is still active. That's true, because we still have about two minutes left being 841. Okay, let's go ahead and check out what we did here and let's see if this helps. Let's actually, we don't need to call view will disappear, we'll just deinitialize it because whenever the view controller goes away, it's initialized by Swift. We also need to call this on detail VC like so let's go ahead and put it right beneath view will disappear like so and you know what? It looks like we are removing it from view will disappear. So call deinit and remove the observers here, guys. So go ahead and call notification center dot default dot remove observer and call self, okay? Whoo, so now whenever this view controller is deinitialized, it's going to remove that observer and that way we won't accidentally get observers that are just kind of locked in memory for when the app opens again. Okay, so you know what we're actually going to do, we're going to call deinit and whenever this view controller is deinitialized, we're going to just remove all the observers on this view controller. I am surprised we have not noticed that until right now. We are adding observers for these notifications, but we are never removing them. What are we missing? We are missing a very important thing. Let's think about what we could be missing here. Let's go ahead and let's go into storefront VC. That is not doing what it's supposed to be doing. It actually bought a new subscription for us. It says subscription active and when we loaded up the app, look at that. Our subscription should be expired from the last video and let's go ahead and check this out. Let's go see if this helps to fix our problem. We are also setting the non-consumable purchase to be true. We're going to paste it and then we're actually going to break, okay? So there we go, beautiful. ![]() Now, let's go ahead and let's type that here. Because at that point, we have succeeded as well. And then what we're going to do is we're going to actually call the same code from this function right here for a successful subscription. Let's call case IAP mealtime monthly sub. So let's go ahead and let's actually modify complete to be the way it was before. Because that implies that our function up here is going to get called every single time and we want to make sure that it gets called. So that's being called, but you know what? I don't really like how I'm not sending a notification when I actually buy it. And that will basically just print out when the user taps the buy button until they either purchase, restore, fail, or defer. We'll call debug print and we'll just say purchasing, I can't type purchasing dot dot dot. And you know what while we're purchasing, why don't we go ahead and handle that as well. Let's say someone can't pay, we're going to go ahead and call finished transaction there as well. So what we can also do is think about what happens if payment is deferred. So let's go ahead and let's actually put that up beneath complete and we're also going to go ahead and put failed beneath the notification just to be consistent. We're telling it to be done before we're done using the data. And I'm trying to figure out why that is, but I think what it boils down to is that we are calling finished transaction before we're actually completing. So it appears that request did finish, is not being called when the actual purchase is being made. Let's go ahead and pull open our xcode project and let's troubleshoot this, let's figure out what the reason for our problems are. Where basically we were not able to show the changes made in a subscription when we wanted to be showing them. And in this video, we're going to go ahead and fix those problems we were just having in the previous video.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |