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

Adapty Flutter SDK with SceneDelegate #98

Open
kingsglade opened this issue Dec 28, 2023 · 4 comments
Open

Adapty Flutter SDK with SceneDelegate #98

kingsglade opened this issue Dec 28, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@kingsglade
Copy link

kingsglade commented Dec 28, 2023

Hi All,

Apologies in advance, this is a very specific issue where I'm trying to get two mature Flutter packages to play nice. I'm in the process of implementing both CarPlay and Adapty for my flutter app and ran into a blocker which I overcame but only with an unpleasant hack.

Dependencies:

  • To implement CarPlay (see https://pub.dev/packages/flutter_carplay) it's required that we implement a SceneDelegate as detailed on their package info, see Getting Started step 3.
  • To have the Adapty SDK work properly we need application(didFinishLaunchingWithOptions) callback to trigger in module SwiftAdaptyFlutterPlugin because it's required that activateOnLaunch() execute to pull the settings from the Adapty-Info.plist

Problem statement: My CarPlay app is functioning normally but my Adapty integration that was previously working now does not. Debugging suggests this is because we're using a SceneDelegate to register plugins and subsequently the callback application(didFinishLaunchingWithOptions) doesn't trigger so Adapty doesn't initialise. We then get an error when trying to use any subsequent Adapty functions such as GetProfile.

Now to the hack: Fortunately setLogLevel works, so I've added the hackiest of hack calls to activateOnLaunch() in module SwiftAdaptyFlutterPlugin just before the line Adapty.logLevel = logLevel in function handleSetLogLevel. I mainly wanted to see if this would work given the timing of the call and good news is that it does and my Adapty paywall is now working, but there are probably some gotchas that I'm not aware of!

Steps To Reproduce: Follow both flutter_carplay (1.0.3) and Adapty (2.7.1) standard implementation steps (a shortcut would be to add Adapty to the flutter_carplay sample app).

Question: Is it possible for a) Adapty to trap SceneDelegate lifecycle callbacks that are similar/equivalent to application(didFinishLaunchingWithOptions) so as to ensure that Adapty initialises in this scenario or b) Allow control from early in the Flutter lifecycle to call Activate() or similar manually.

I get that there's a reason the activation is being done automatically so as to play nice with StoreKit but unless I put this hack in or implement another custom method call in the SDK I can't see this being resolved. I'm pretty sure the CarPlay solution needs to retain the SceneDelegate approach.

Thanks in advance for your assistance!
Mark

@x401om
Copy link
Collaborator

x401om commented Dec 29, 2023

Hi, @kingsglade! Thank you for the interesting issue, we will discuss your case internally and try to reproduce it. I hope we'll be able to suggest a solution for you soon!

@x401om x401om added the enhancement New feature or request label Feb 23, 2024
@kingsglade
Copy link
Author

Hi, just catching up on this earlier issue - were you able to reproduce it? Many thanks

@x401om
Copy link
Collaborator

x401om commented Jul 10, 2024

Hi @kingsglade! I apologize for the late response; our team has been really busy preparing the new release for iOS. I think we will add an option for manual activation for Adapty Flutter, as well as an automatic one, which will resolve your original issue.

@kingsglade
Copy link
Author

Many thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants